@@ -284,26 +284,33 @@ func opBenchmark(bench *testing.B, op executionFunc, args ...string) {
284284 var (
285285 env = NewEVM (BlockContext {}, TxContext {}, nil , params .TestChainConfig , Config {})
286286 stack = newstack ()
287+ scope = & ScopeContext {nil , stack , nil }
287288 evmInterpreter = NewEVMInterpreter (env , env .Config )
288289 )
289290
290291 env .interpreter = evmInterpreter
291292 // convert args
292- byteArgs := make ([][] byte , len (args ))
293+ intArgs := make ([]* uint256. Int , len (args ))
293294 for i , arg := range args {
294- byteArgs [i ] = common .Hex2Bytes (arg )
295+ intArgs [i ] = new (uint256. Int ). SetBytes ( common .Hex2Bytes (arg ) )
295296 }
296297 pc := uint64 (0 )
297298 bench .ResetTimer ()
298299 for i := 0 ; i < bench .N ; i ++ {
299- for _ , arg := range byteArgs {
300- a := new (uint256.Int )
301- a .SetBytes (arg )
302- stack .push (a )
300+ for _ , arg := range intArgs {
301+ stack .push (arg )
303302 }
304- op (& pc , evmInterpreter , & ScopeContext { nil , stack , nil } )
303+ op (& pc , evmInterpreter , scope )
305304 stack .pop ()
306305 }
306+ bench .StopTimer ()
307+
308+ for i , arg := range args {
309+ want := new (uint256.Int ).SetBytes (common .Hex2Bytes (arg ))
310+ if have := intArgs [i ]; ! want .Eq (have ) {
311+ bench .Fatalf ("input #%d mutated, have %x want %x" , i , have , want )
312+ }
313+ }
307314}
308315
309316func BenchmarkOpAdd64 (b * testing.B ) {
0 commit comments