neo-go/pkg/core/fee/opcode_test.go
Roman Khimov 3c1325035e fee: use array for opcodes
Use less memory and have faster access.

name       old time/op  new time/op  delta
Opcode1-8  22.4ns ± 6%   3.0ns ± 6%  -86.63%  (p=0.000 n=10+10)
2021-08-02 20:18:33 +03:00

19 lines
439 B
Go

package fee
import (
"testing"
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
)
const feeFactor = 30
// The most common Opcode() use case is to get price for single opcode.
func BenchmarkOpcode1(t *testing.B) {
// Just so that we don't always test the same opcode.
script := []opcode.Opcode{opcode.NOP, opcode.ADD, opcode.SYSCALL, opcode.APPEND}
l := len(script)
for n := 0; n < t.N; n++ {
_ = Opcode(feeFactor, script[n%l])
}
}