mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-25 23:42:23 +00:00
1b83dc2476
Mostly it's about Go 1.22+ syntax with ranging over integers, but it also prefers ranging over slices where possible (it makes code a little better to read). Notice that we have a number of dangerous loops where slices are mutated during loop execution, many of these can't be converted since we need proper length evalutation at every iteration. Signed-off-by: Roman Khimov <roman@nspcc.ru>
19 lines
435 B
Go
19 lines
435 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 a 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 := range t.N {
|
|
_ = Opcode(feeFactor, script[n%l])
|
|
}
|
|
}
|