Try without recurson

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2020-06-28 18:41:03 +02:00
parent 4db61e71da
commit 9094405537
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA

View File

@ -360,6 +360,7 @@ var importAnalyzeCmd = &cli.Command{
}
totalTime += tse.Duration
var execStack = make([]types.ExecutionTrace, 0, 100)
for _, inv := range tse.Trace {
if inv.Duration > leastExpensiveInvoc {
expensiveInvocs = append(expensiveInvocs, Invocation{
@ -367,8 +368,33 @@ var importAnalyzeCmd = &cli.Command{
Invoc: inv,
})
}
execStack = append(execStack, inv.ExecutionTrace)
for len(execStack) != 0 {
et := execStack[len(execStack)-1]
execStack = execStack[:len(execStack)-1]
for _, gc := range et.GasCharges {
tallyGasCharges(chargeStats, inv.ExecutionTrace)
compGas := gc.ComputeGas
if compGas == 0 {
compGas = 1
}
ratio := float64(compGas) / float64(gc.TimeTaken.Nanoseconds())
ratio = 1 / ratio
if math.IsNaN(ratio) {
log.Errorf("NaN: comGas: %f, taken: %d", compGas, gc.TimeTaken.Nanoseconds())
}
s := chargeStats[gc.Name]
if s == nil {
s = new(stats)
chargeStats[gc.Name] = s
}
s.AddPoint(ratio)
}
execStack = append(execStack, et.Subcalls...)
}
}
if len(expensiveInvocs) > 4*invocsKeep {
sort.Slice(expensiveInvocs, func(i, j int) bool {