mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
added more "real-world" benchmarks
This commit is contained in:
parent
449d3f0d87
commit
21f7bc79ae
2 changed files with 32 additions and 0 deletions
|
|
@ -17,9 +17,12 @@
|
||||||
package vm
|
package vm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/rand"
|
||||||
|
_ "embed"
|
||||||
"math/bits"
|
"math/bits"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -71,6 +74,34 @@ func BenchmarkJumpdestAnalysis_1200k(bench *testing.B) {
|
||||||
}
|
}
|
||||||
bench.StopTimer()
|
bench.StopTimer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkJumpdestAnalysis_rand(b *testing.B) {
|
||||||
|
code := make([]byte, analysisCodeSize)
|
||||||
|
rand.Read(code)
|
||||||
|
|
||||||
|
bv := codeBitmap(code)
|
||||||
|
b.SetBytes(int64(len(code)))
|
||||||
|
b.ResetTimer()
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
codeBitmapInternal(code, bv)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
//go:embed testdata/weth9.bytecode
|
||||||
|
hexCodeWETH9 string
|
||||||
|
codeWETH9 = common.FromHex(hexCodeWETH9)
|
||||||
|
)
|
||||||
|
|
||||||
|
func BenchmarkJumpdestAnalysis_weth9(b *testing.B) {
|
||||||
|
bv := codeBitmap(codeWETH9)
|
||||||
|
b.SetBytes(int64(len(codeWETH9)))
|
||||||
|
b.ResetTimer()
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
codeBitmapInternal(codeWETH9, bv)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkJumpdestHashing_1200k(bench *testing.B) {
|
func BenchmarkJumpdestHashing_1200k(bench *testing.B) {
|
||||||
// 4 ms
|
// 4 ms
|
||||||
code := make([]byte, analysisCodeSize)
|
code := make([]byte, analysisCodeSize)
|
||||||
|
|
|
||||||
1
core/vm/testdata/weth9.bytecode
vendored
Normal file
1
core/vm/testdata/weth9.bytecode
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue