cmd: using testing.B.Loop

This commit is contained in:
rizkyikiw42 2025-09-21 23:24:00 +08:00
parent 4414e2833f
commit 26b44a5c1e
2 changed files with 3 additions and 4 deletions

View file

@ -880,7 +880,7 @@ func BenchmarkDecodeRLPLogs(b *testing.B) {
b.Run("ReceiptForStorage", func(b *testing.B) { b.Run("ReceiptForStorage", func(b *testing.B) {
b.ReportAllocs() b.ReportAllocs()
var r []*types.ReceiptForStorage var r []*types.ReceiptForStorage
for i := 0; i < b.N; i++ { for b.Loop() {
if err := rlp.DecodeBytes(buf, &r); err != nil { if err := rlp.DecodeBytes(buf, &r); err != nil {
b.Fatal(err) b.Fatal(err)
} }
@ -889,7 +889,7 @@ func BenchmarkDecodeRLPLogs(b *testing.B) {
b.Run("rlpLogs", func(b *testing.B) { b.Run("rlpLogs", func(b *testing.B) {
b.ReportAllocs() b.ReportAllocs()
var r []*receiptLogs var r []*receiptLogs
for i := 0; i < b.N; i++ { for b.Loop() {
if err := rlp.DecodeBytes(buf, &r); err != nil { if err := rlp.DecodeBytes(buf, &r); err != nil {
b.Fatal(err) b.Fatal(err)
} }

View file

@ -2168,8 +2168,7 @@ func benchmarkPoolPending(b *testing.B, datacap uint64) {
// Benchmark assembling the pending // Benchmark assembling the pending
b.ResetTimer() b.ResetTimer()
b.ReportAllocs() b.ReportAllocs()
for b.Loop() {
for i := 0; i < b.N; i++ {
p := pool.Pending(txpool.PendingFilter{ p := pool.Pending(txpool.PendingFilter{
MinTip: uint256.NewInt(1), MinTip: uint256.NewInt(1),
BaseFee: chain.basefee, BaseFee: chain.basefee,