From 5e7f5611338e3f19fc931e233b05601de3f94d31 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Tue, 30 Jun 2020 02:56:58 +0200 Subject: [PATCH] Support complex extra, fix small bug in covariance Signed-off-by: Jakub Sztandera --- cmd/lotus-bench/import.go | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/cmd/lotus-bench/import.go b/cmd/lotus-bench/import.go index f9526e90f..7d759642e 100644 --- a/cmd/lotus-bench/import.go +++ b/cmd/lotus-bench/import.go @@ -296,7 +296,7 @@ func (cov1 *covar) Combine(cov2 *covar) { out.m2 = cov1.m2 + cov2.m2 + dx*dx*cov1.n*cov2.n/out.n dy := cov1.meanY - cov2.meanY - out.meanY = cov1.meanY + dy*cov2.n/out.n + out.meanY = cov1.meanY - dy*cov2.n/out.n out.c = cov1.c + cov2.c + dx*dy*cov1.n*cov2.n/out.n *cov1 = out @@ -362,6 +362,30 @@ func (v1 *meanVar) Combine(v2 *meanVar) { v1.m2 = m2 } +func getExtras(ex interface{}) (*string, *float64) { + if t, ok := ex.(string); ok { + return &t, nil + } + if size, ok := ex.(float64); ok { + return nil, &size + } + if exMap, ok := ex.(map[string]interface{}); ok { + t, tok := exMap["type"].(string) + size, sok := exMap["size"].(float64) + if tok && sok { + return &t, &size + } + if tok { + return &t, nil + } + if sok { + return nil, &size + } + return nil, nil + } + return nil, nil +} + func tallyGasCharges(charges map[string]*stats, et types.ExecutionTrace) { for i, gc := range et.GasCharges { name := gc.Name @@ -376,8 +400,9 @@ func tallyGasCharges(charges map[string]*stats, et types.ExecutionTrace) { } tt += float64(prev.TimeTaken.Nanoseconds()) } - if eString, ok := gc.Extra.(string); ok { - name += "-" + eString + eType, eSize := getExtras(gc.Extra) + if eType != nil { + name += "-" + *eType } compGas := gc.VirtualComputeGas if compGas == 0 { @@ -389,13 +414,13 @@ func tallyGasCharges(charges map[string]*stats, et types.ExecutionTrace) { charges[name] = s } - if extra, ok := gc.Extra.(float64); ok { + if eSize != nil { if s.extraCovar == nil { s.extraCovar = &covar{} s.extra = &meanVar{} } - s.extraCovar.AddPoint(extra, tt) - s.extra.AddPoint(extra) + s.extraCovar.AddPoint(*eSize, tt) + s.extra.AddPoint(*eSize) } s.timeTaken.AddPoint(tt)