core/vm: replace repeated string with variable in tests (#22774)

This commit is contained in:
aaronbuchwald 2021-04-30 06:49:13 -04:00 committed by GitHub
parent 1e57ab5de6
commit dde6cb0b92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,6 +40,7 @@ type twoOperandParams struct {
y string y string
} }
var alphabetSoup = "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
var commonParams []*twoOperandParams var commonParams []*twoOperandParams
var twoOpMethods map[string]executionFunc var twoOpMethods map[string]executionFunc
@ -347,8 +348,8 @@ func BenchmarkOpSub256(b *testing.B) {
} }
func BenchmarkOpMul(b *testing.B) { func BenchmarkOpMul(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" x := alphabetSoup
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" y := alphabetSoup
opBenchmark(b, opMul, x, y) opBenchmark(b, opMul, x, y)
} }
@ -379,64 +380,64 @@ func BenchmarkOpSdiv(b *testing.B) {
} }
func BenchmarkOpMod(b *testing.B) { func BenchmarkOpMod(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" x := alphabetSoup
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" y := alphabetSoup
opBenchmark(b, opMod, x, y) opBenchmark(b, opMod, x, y)
} }
func BenchmarkOpSmod(b *testing.B) { func BenchmarkOpSmod(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" x := alphabetSoup
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" y := alphabetSoup
opBenchmark(b, opSmod, x, y) opBenchmark(b, opSmod, x, y)
} }
func BenchmarkOpExp(b *testing.B) { func BenchmarkOpExp(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" x := alphabetSoup
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" y := alphabetSoup
opBenchmark(b, opExp, x, y) opBenchmark(b, opExp, x, y)
} }
func BenchmarkOpSignExtend(b *testing.B) { func BenchmarkOpSignExtend(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" x := alphabetSoup
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" y := alphabetSoup
opBenchmark(b, opSignExtend, x, y) opBenchmark(b, opSignExtend, x, y)
} }
func BenchmarkOpLt(b *testing.B) { func BenchmarkOpLt(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" x := alphabetSoup
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" y := alphabetSoup
opBenchmark(b, opLt, x, y) opBenchmark(b, opLt, x, y)
} }
func BenchmarkOpGt(b *testing.B) { func BenchmarkOpGt(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" x := alphabetSoup
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" y := alphabetSoup
opBenchmark(b, opGt, x, y) opBenchmark(b, opGt, x, y)
} }
func BenchmarkOpSlt(b *testing.B) { func BenchmarkOpSlt(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" x := alphabetSoup
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" y := alphabetSoup
opBenchmark(b, opSlt, x, y) opBenchmark(b, opSlt, x, y)
} }
func BenchmarkOpSgt(b *testing.B) { func BenchmarkOpSgt(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" x := alphabetSoup
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" y := alphabetSoup
opBenchmark(b, opSgt, x, y) opBenchmark(b, opSgt, x, y)
} }
func BenchmarkOpEq(b *testing.B) { func BenchmarkOpEq(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" x := alphabetSoup
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" y := alphabetSoup
opBenchmark(b, opEq, x, y) opBenchmark(b, opEq, x, y)
} }
@ -446,45 +447,45 @@ func BenchmarkOpEq2(b *testing.B) {
opBenchmark(b, opEq, x, y) opBenchmark(b, opEq, x, y)
} }
func BenchmarkOpAnd(b *testing.B) { func BenchmarkOpAnd(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" x := alphabetSoup
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" y := alphabetSoup
opBenchmark(b, opAnd, x, y) opBenchmark(b, opAnd, x, y)
} }
func BenchmarkOpOr(b *testing.B) { func BenchmarkOpOr(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" x := alphabetSoup
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" y := alphabetSoup
opBenchmark(b, opOr, x, y) opBenchmark(b, opOr, x, y)
} }
func BenchmarkOpXor(b *testing.B) { func BenchmarkOpXor(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" x := alphabetSoup
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" y := alphabetSoup
opBenchmark(b, opXor, x, y) opBenchmark(b, opXor, x, y)
} }
func BenchmarkOpByte(b *testing.B) { func BenchmarkOpByte(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" x := alphabetSoup
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" y := alphabetSoup
opBenchmark(b, opByte, x, y) opBenchmark(b, opByte, x, y)
} }
func BenchmarkOpAddmod(b *testing.B) { func BenchmarkOpAddmod(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" x := alphabetSoup
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" y := alphabetSoup
z := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" z := alphabetSoup
opBenchmark(b, opAddmod, x, y, z) opBenchmark(b, opAddmod, x, y, z)
} }
func BenchmarkOpMulmod(b *testing.B) { func BenchmarkOpMulmod(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" x := alphabetSoup
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" y := alphabetSoup
z := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" z := alphabetSoup
opBenchmark(b, opMulmod, x, y, z) opBenchmark(b, opMulmod, x, y, z)
} }