cmd/evm: resolve conflict in evm benchmarking

This commit is contained in:
Manav Darji 2025-03-25 16:20:47 +05:30
parent c0d0b1cb06
commit 6f42b5a43e
No known key found for this signature in database
GPG key ID: A426F0124435F36E

View file

@ -106,21 +106,13 @@ func timedExec(bench bool, execFunc func() ([]byte, uint64, error)) ([]byte, exe
}) })
// Get the average execution time from the benchmarking result. // Get the average execution time from the benchmarking result.
// There are other useful stats here that could be reported. // There are other useful stats here that could be reported.
stats.time = time.Duration(result.NsPerOp()) stats := execStats{
stats.allocs = result.AllocsPerOp() Time: time.Duration(result.NsPerOp()),
stats.bytesAllocated = result.AllocedBytesPerOp() Allocs: result.AllocsPerOp(),
} else { BytesAllocated: result.AllocedBytesPerOp(),
var memStatsBefore, memStatsAfter goruntime.MemStats GasUsed: gasUsed,
}
goruntime.ReadMemStats(&memStatsBefore) return output, stats, err
startTime := time.Now()
output, gasLeft, err = execFunc()
stats.time = time.Since(startTime)
goruntime.ReadMemStats(&memStatsAfter)
stats.allocs = int64(memStatsAfter.Mallocs - memStatsBefore.Mallocs)
stats.bytesAllocated = int64(memStatsAfter.TotalAlloc - memStatsBefore.TotalAlloc)
} }
var memStatsBefore, memStatsAfter goruntime.MemStats var memStatsBefore, memStatsAfter goruntime.MemStats
goruntime.ReadMemStats(&memStatsBefore) goruntime.ReadMemStats(&memStatsBefore)