mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 05:06:43 +00:00
triedb: using testing.B.Loop
Signed-off-by: yajianggroup <yajianggroup@outlook.com>
This commit is contained in:
parent
2872242045
commit
a5039f98b9
3 changed files with 13 additions and 17 deletions
|
|
@ -83,13 +83,12 @@ func benchmarkSearch(b *testing.B, depth int, total int) {
|
||||||
for i := 0; i < total; i++ {
|
for i := 0; i < total; i++ {
|
||||||
layer = fill(layer, i)
|
layer = fill(layer, i)
|
||||||
}
|
}
|
||||||
b.ResetTimer()
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
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 +119,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()
|
||||||
|
|
@ -163,9 +162,8 @@ func BenchmarkJournal(b *testing.B) {
|
||||||
for i := 0; i < 128; i++ {
|
for i := 0; i < 128; i++ {
|
||||||
layer = fill(layer)
|
layer = fill(layer)
|
||||||
}
|
}
|
||||||
b.ResetTimer()
|
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
layer.journal(new(bytes.Buffer))
|
layer.journal(new(bytes.Buffer))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -224,8 +224,7 @@ func BenchmarkParseIndexBlock(b *testing.B) {
|
||||||
}
|
}
|
||||||
blob := bw.finish()
|
blob := bw.finish()
|
||||||
|
|
||||||
b.ResetTimer()
|
for b.Loop() {
|
||||||
for i := 0; i < b.N; i++ {
|
|
||||||
_, _, err := parseIndexBlock(blob)
|
_, _, err := parseIndexBlock(blob)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("parseIndexBlock failed: %v", err)
|
b.Fatalf("parseIndexBlock failed: %v", err)
|
||||||
|
|
@ -236,12 +235,11 @@ func BenchmarkParseIndexBlock(b *testing.B) {
|
||||||
// BenchmarkBlockWriterAppend benchmarks the performance of indexblock.writer
|
// BenchmarkBlockWriterAppend benchmarks the performance of indexblock.writer
|
||||||
func BenchmarkBlockWriterAppend(b *testing.B) {
|
func BenchmarkBlockWriterAppend(b *testing.B) {
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
b.ResetTimer()
|
|
||||||
|
|
||||||
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