core/vm: use a callcontext struct (#20761)
* core/vm: use a callcontext struct * core/vm: fix tests * core/vm/runtime: benchmark * core/vm: make intpool push inlineable, unexpose callcontext
This commit is contained in:
committed by
GitHub
parent
0bec6a43f6
commit
8dc8941551
@ -316,3 +316,31 @@ func TestBlockhash(t *testing.T) {
|
||||
t.Errorf("suboptimal; too much chain iteration, expected %d, got %d", exp, got)
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkSimpleLoop test a pretty simple loop which loops
|
||||
// 1M (1 048 575) times.
|
||||
// Takes about 200 ms
|
||||
func BenchmarkSimpleLoop(b *testing.B) {
|
||||
// 0xfffff = 1048575 loops
|
||||
code := []byte{
|
||||
byte(vm.PUSH3), 0x0f, 0xff, 0xff,
|
||||
byte(vm.JUMPDEST), // [ count ]
|
||||
byte(vm.PUSH1), 1, // [count, 1]
|
||||
byte(vm.SWAP1), // [1, count]
|
||||
byte(vm.SUB), // [ count -1 ]
|
||||
byte(vm.DUP1), // [ count -1 , count-1]
|
||||
byte(vm.PUSH1), 4, // [count-1, count -1, label]
|
||||
byte(vm.JUMPI), // [ 0 ]
|
||||
byte(vm.STOP),
|
||||
}
|
||||
//tracer := vm.NewJSONLogger(nil, os.Stdout)
|
||||
//Execute(code, nil, &Config{
|
||||
// EVMConfig: vm.Config{
|
||||
// Debug: true,
|
||||
// Tracer: tracer,
|
||||
// }})
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
Execute(code, nil, nil)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user