mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-30 09:33:36 +00:00
2c2ccdca74
Map access costs much more than array access. name old time/op new time/op delta IsValid-8 17.6ns ± 2% 1.1ns ± 2% -93.68% (p=0.008 n=5+5)
15 lines
318 B
Go
15 lines
318 B
Go
package opcode
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
// IsValid() is called for every VM instruction.
|
|
func BenchmarkIsValid(t *testing.B) {
|
|
// Just so that we don't always test the same opcode.
|
|
script := []Opcode{NOP, ADD, SYSCALL, APPEND, 0xff, 0xf0}
|
|
l := len(script)
|
|
for n := 0; n < t.N; n++ {
|
|
_ = IsValid(script[n%l])
|
|
}
|
|
}
|