Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions core/types/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,8 @@ var benchBuffer = bytes.NewBuffer(make([]byte, 0, 32000))

func BenchmarkEncodeBlock(b *testing.B) {
block := makeBenchBlock()
b.ResetTimer()

for i := 0; i < b.N; i++ {
for b.Loop() {
benchBuffer.Reset()
if err := rlp.Encode(benchBuffer, block); err != nil {
b.Fatal(err)
Expand Down
16 changes: 6 additions & 10 deletions core/types/bloom9_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ func TestBloomExtensively(t *testing.T) {

func BenchmarkBloom9(b *testing.B) {
test := []byte("testestestest")
for i := 0; i < b.N; i++ {
for b.Loop() {
Bloom9(test)
}
}

func BenchmarkBloom9Lookup(b *testing.B) {
toTest := []byte("testtest")
bloom := new(Bloom)
for i := 0; i < b.N; i++ {
for b.Loop() {
bloom.Test(toTest)
}
}
Expand Down Expand Up @@ -128,7 +128,7 @@ func BenchmarkCreateBloom(b *testing.B) {
}
b.Run("small-createbloom", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for b.Loop() {
for _, receipt := range rSmall {
receipt.Bloom = CreateBloom(receipt)
}
Expand All @@ -144,7 +144,7 @@ func BenchmarkCreateBloom(b *testing.B) {
})
b.Run("large-createbloom", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for b.Loop() {
for _, receipt := range rLarge {
receipt.Bloom = CreateBloom(receipt)
}
Expand All @@ -163,13 +163,11 @@ func BenchmarkCreateBloom(b *testing.B) {
receipt.Bloom = CreateBloom(receipt)
}
b.ReportAllocs()
b.ResetTimer()

var bl Bloom
for i := 0; i < b.N; i++ {
for b.Loop() {
bl = MergeBloom(rSmall)
}
b.StopTimer()

var exp = common.HexToHash("c384c56ece49458a427c67b90fefe979ebf7104795be65dc398b280f24104949")
got := crypto.Keccak256Hash(bl.Bytes())
Expand All @@ -182,13 +180,11 @@ func BenchmarkCreateBloom(b *testing.B) {
receipt.Bloom = CreateBloom(receipt)
}
b.ReportAllocs()
b.ResetTimer()

var bl Bloom
for i := 0; i < b.N; i++ {
for b.Loop() {
bl = MergeBloom(rLarge)
}
b.StopTimer()

var exp = common.HexToHash("c384c56ece49458a427c67b90fefe979ebf7104795be65dc398b280f24104949")
got := crypto.Keccak256Hash(bl.Bytes())
Expand Down
5 changes: 2 additions & 3 deletions core/types/hashing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,16 @@ func BenchmarkDeriveSha200(b *testing.B) {
var exp common.Hash
var got common.Hash
b.Run("std_trie", func(b *testing.B) {
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for b.Loop() {
exp = types.DeriveSha(txs, trie.NewEmpty(triedb.NewDatabase(rawdb.NewMemoryDatabase(), nil)))
}
})

b.Run("stack_trie", func(b *testing.B) {
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for b.Loop() {
got = types.DeriveSha(txs, trie.NewStackTrie(nil))
}
})
Expand Down
8 changes: 4 additions & 4 deletions core/types/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ func BenchmarkHash(b *testing.B) {
GasTipCap: big.NewInt(500),
GasFeeCap: big.NewInt(500),
})
for i := 0; i < b.N; i++ {
for b.Loop() {
signer.Hash(tx)
}
}
Expand All @@ -614,7 +614,7 @@ func BenchmarkEffectiveGasTip(b *testing.B) {

b.Run("Original", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for b.Loop() {
_, err := tx.EffectiveGasTip(baseFee.ToBig())
if err != nil {
b.Fatal(err)
Expand All @@ -625,7 +625,7 @@ func BenchmarkEffectiveGasTip(b *testing.B) {
b.Run("IntoMethod", func(b *testing.B) {
b.ReportAllocs()
dst := new(uint256.Int)
for i := 0; i < b.N; i++ {
for b.Loop() {
err := tx.calcEffectiveGasTip(dst, baseFee)
if err != nil {
b.Fatal(err)
Expand Down Expand Up @@ -729,7 +729,7 @@ func BenchmarkEffectiveGasTipCmp(b *testing.B) {

b.Run("Original", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for b.Loop() {
tx.EffectiveGasTipCmp(other, baseFee)
}
})
Expand Down
4 changes: 2 additions & 2 deletions core/types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func benchRLP(b *testing.B, encode bool) {
b.Run(tc.name, func(b *testing.B) {
b.ReportAllocs()
var null = &devnull{}
for i := 0; i < b.N; i++ {
for b.Loop() {
rlp.Encode(null, tc.obj)
}
b.SetBytes(int64(null.len / b.N))
Expand All @@ -136,7 +136,7 @@ func benchRLP(b *testing.B, encode bool) {
// Test decoding
b.Run(tc.name, func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for b.Loop() {
if err := rlp.DecodeBytes(data, tc.obj); err != nil {
b.Fatal(err)
}
Expand Down