mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 05:06:43 +00:00
triedb: using testing.B.Loop
This commit is contained in:
parent
1e4b39ed12
commit
7405f179ff
3 changed files with 13 additions and 13 deletions
|
|
@ -89,7 +89,7 @@ func benchmarkSearch(b *testing.B, depth int, total int) {
|
||||||
have []byte
|
have []byte
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
have, _, _, err = layer.node(common.Hash{}, npath, 0)
|
have, _, _, err = layer.node(common.Hash{}, npath, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
|
|
@ -120,7 +120,7 @@ func BenchmarkPersist(b *testing.B) {
|
||||||
}
|
}
|
||||||
return newDiffLayer(parent, common.Hash{}, 0, 0, NewNodeSetWithOrigin(nodes, nil), NewStateSetWithOrigin(nil, nil, nil, nil, false))
|
return newDiffLayer(parent, common.Hash{}, 0, 0, NewNodeSetWithOrigin(nodes, nil), NewStateSetWithOrigin(nil, nil, nil, nil, false))
|
||||||
}
|
}
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
b.StopTimer()
|
b.StopTimer()
|
||||||
var layer layer
|
var layer layer
|
||||||
layer = emptyLayer()
|
layer = emptyLayer()
|
||||||
|
|
@ -165,7 +165,7 @@ func BenchmarkJournal(b *testing.B) {
|
||||||
}
|
}
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
layer.journal(new(bytes.Buffer))
|
layer.journal(new(bytes.Buffer))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,7 @@ func BenchmarkParseIndexBlock(b *testing.B) {
|
||||||
blob := bw.finish()
|
blob := bw.finish()
|
||||||
|
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
_, _, err := parseIndexBlock(blob)
|
_, _, err := parseIndexBlock(blob)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("parseIndexBlock failed: %v", err)
|
b.Fatalf("parseIndexBlock failed: %v", err)
|
||||||
|
|
@ -241,7 +241,7 @@ func BenchmarkBlockWriterAppend(b *testing.B) {
|
||||||
desc := newIndexBlockDesc(0)
|
desc := newIndexBlockDesc(0)
|
||||||
writer, _ := newBlockWriter(nil, desc)
|
writer, _ := newBlockWriter(nil, desc)
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
if writer.full() {
|
if writer.full() {
|
||||||
desc = newIndexBlockDesc(0)
|
desc = newIndexBlockDesc(0)
|
||||||
writer, _ = newBlockWriter(nil, desc)
|
writer, _ = newBlockWriter(nil, desc)
|
||||||
|
|
|
||||||
|
|
@ -1051,7 +1051,7 @@ func BenchmarkAccountIteratorTraversal(b *testing.B) {
|
||||||
head.(*diffLayer).newBinaryAccountIterator(common.Hash{})
|
head.(*diffLayer).newBinaryAccountIterator(common.Hash{})
|
||||||
|
|
||||||
b.Run("binary iterator keys", func(b *testing.B) {
|
b.Run("binary iterator keys", func(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
got := 0
|
got := 0
|
||||||
it := head.(*diffLayer).newBinaryAccountIterator(common.Hash{})
|
it := head.(*diffLayer).newBinaryAccountIterator(common.Hash{})
|
||||||
for it.Next() {
|
for it.Next() {
|
||||||
|
|
@ -1063,7 +1063,7 @@ func BenchmarkAccountIteratorTraversal(b *testing.B) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
b.Run("binary iterator values", func(b *testing.B) {
|
b.Run("binary iterator values", func(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
got := 0
|
got := 0
|
||||||
it := head.(*diffLayer).newBinaryAccountIterator(common.Hash{})
|
it := head.(*diffLayer).newBinaryAccountIterator(common.Hash{})
|
||||||
for it.Next() {
|
for it.Next() {
|
||||||
|
|
@ -1076,7 +1076,7 @@ func BenchmarkAccountIteratorTraversal(b *testing.B) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
b.Run("fast iterator keys", func(b *testing.B) {
|
b.Run("fast iterator keys", func(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
it, _ := db.AccountIterator(common.HexToHash("0x65"), common.Hash{})
|
it, _ := db.AccountIterator(common.HexToHash("0x65"), common.Hash{})
|
||||||
defer it.Release()
|
defer it.Release()
|
||||||
|
|
||||||
|
|
@ -1090,7 +1090,7 @@ func BenchmarkAccountIteratorTraversal(b *testing.B) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
b.Run("fast iterator values", func(b *testing.B) {
|
b.Run("fast iterator values", func(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
it, _ := db.AccountIterator(common.HexToHash("0x65"), common.Hash{})
|
it, _ := db.AccountIterator(common.HexToHash("0x65"), common.Hash{})
|
||||||
defer it.Release()
|
defer it.Release()
|
||||||
|
|
||||||
|
|
@ -1142,7 +1142,7 @@ func BenchmarkAccountIteratorLargeBaselayer(b *testing.B) {
|
||||||
head.(*diffLayer).newBinaryAccountIterator(common.Hash{})
|
head.(*diffLayer).newBinaryAccountIterator(common.Hash{})
|
||||||
|
|
||||||
b.Run("binary iterator (keys)", func(b *testing.B) {
|
b.Run("binary iterator (keys)", func(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
got := 0
|
got := 0
|
||||||
it := head.(*diffLayer).newBinaryAccountIterator(common.Hash{})
|
it := head.(*diffLayer).newBinaryAccountIterator(common.Hash{})
|
||||||
for it.Next() {
|
for it.Next() {
|
||||||
|
|
@ -1154,7 +1154,7 @@ func BenchmarkAccountIteratorLargeBaselayer(b *testing.B) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
b.Run("binary iterator (values)", func(b *testing.B) {
|
b.Run("binary iterator (values)", func(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
got := 0
|
got := 0
|
||||||
it := head.(*diffLayer).newBinaryAccountIterator(common.Hash{})
|
it := head.(*diffLayer).newBinaryAccountIterator(common.Hash{})
|
||||||
for it.Next() {
|
for it.Next() {
|
||||||
|
|
@ -1168,7 +1168,7 @@ func BenchmarkAccountIteratorLargeBaselayer(b *testing.B) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
b.Run("fast iterator (keys)", func(b *testing.B) {
|
b.Run("fast iterator (keys)", func(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
it, _ := db.AccountIterator(common.HexToHash("0x65"), common.Hash{})
|
it, _ := db.AccountIterator(common.HexToHash("0x65"), common.Hash{})
|
||||||
defer it.Release()
|
defer it.Release()
|
||||||
|
|
||||||
|
|
@ -1182,7 +1182,7 @@ func BenchmarkAccountIteratorLargeBaselayer(b *testing.B) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
b.Run("fast iterator (values)", func(b *testing.B) {
|
b.Run("fast iterator (values)", func(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
it, _ := db.AccountIterator(common.HexToHash("0x65"), common.Hash{})
|
it, _ := db.AccountIterator(common.HexToHash("0x65"), common.Hash{})
|
||||||
defer it.Release()
|
defer it.Release()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue