mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth/filters: replace fmt.Println to b.Log in tests.
This commit is contained in:
parent
0c30eff7e1
commit
b315fa938d
1 changed files with 13 additions and 13 deletions
|
|
@ -64,7 +64,7 @@ const benchFilterCnt = 2000
|
||||||
|
|
||||||
func benchmarkBloomBits(b *testing.B, sectionSize uint64) {
|
func benchmarkBloomBits(b *testing.B, sectionSize uint64) {
|
||||||
benchDataDir := node.DefaultDataDir() + "/geth/chaindata"
|
benchDataDir := node.DefaultDataDir() + "/geth/chaindata"
|
||||||
fmt.Println("Running bloombits benchmark section size:", sectionSize)
|
b.Log("Running bloombits benchmark section size:", sectionSize)
|
||||||
|
|
||||||
db, err := rawdb.NewLevelDBDatabase(benchDataDir, 128, 1024, "")
|
db, err := rawdb.NewLevelDBDatabase(benchDataDir, 128, 1024, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -76,7 +76,7 @@ func benchmarkBloomBits(b *testing.B, sectionSize uint64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
clearBloomBits(db)
|
clearBloomBits(db)
|
||||||
fmt.Println("Generating bloombits data...")
|
b.Log("Generating bloombits data...")
|
||||||
headNum := rawdb.ReadHeaderNumber(db, head)
|
headNum := rawdb.ReadHeaderNumber(db, head)
|
||||||
if headNum == nil || *headNum < sectionSize+512 {
|
if headNum == nil || *headNum < sectionSize+512 {
|
||||||
b.Fatalf("not enough blocks for running a benchmark")
|
b.Fatalf("not enough blocks for running a benchmark")
|
||||||
|
|
@ -111,16 +111,16 @@ func benchmarkBloomBits(b *testing.B, sectionSize uint64) {
|
||||||
rawdb.WriteBloomBits(db, uint(i), sectionIdx, sectionHead, comp)
|
rawdb.WriteBloomBits(db, uint(i), sectionIdx, sectionHead, comp)
|
||||||
}
|
}
|
||||||
//if sectionIdx%50 == 0 {
|
//if sectionIdx%50 == 0 {
|
||||||
// fmt.Println(" section", sectionIdx, "/", cnt)
|
// b.Log(" section", sectionIdx, "/", cnt)
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
d := time.Since(start)
|
d := time.Since(start)
|
||||||
fmt.Println("Finished generating bloombits data")
|
b.Log("Finished generating bloombits data")
|
||||||
fmt.Println(" ", d, "total ", d/time.Duration(cnt*sectionSize), "per block")
|
b.Log(" ", d, "total ", d/time.Duration(cnt*sectionSize), "per block")
|
||||||
fmt.Println(" data size:", dataSize, " compressed size:", compSize, " compression ratio:", float64(compSize)/float64(dataSize))
|
b.Log(" data size:", dataSize, " compressed size:", compSize, " compression ratio:", float64(compSize)/float64(dataSize))
|
||||||
|
|
||||||
fmt.Println("Running filter benchmarks...")
|
b.Log("Running filter benchmarks...")
|
||||||
start = time.Now()
|
start = time.Now()
|
||||||
mux := new(event.TypeMux)
|
mux := new(event.TypeMux)
|
||||||
var backend *testBackend
|
var backend *testBackend
|
||||||
|
|
@ -140,8 +140,8 @@ func benchmarkBloomBits(b *testing.B, sectionSize uint64) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d = time.Since(start)
|
d = time.Since(start)
|
||||||
fmt.Println("Finished running filter benchmarks")
|
b.Log("Finished running filter benchmarks")
|
||||||
fmt.Println(" ", d, "total ", d/time.Duration(benchFilterCnt), "per address", d*time.Duration(1000000)/time.Duration(benchFilterCnt*cnt*sectionSize), "per million blocks")
|
b.Log(" ", d, "total ", d/time.Duration(benchFilterCnt), "per address", d*time.Duration(1000000)/time.Duration(benchFilterCnt*cnt*sectionSize), "per million blocks")
|
||||||
db.Close()
|
db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,7 +158,7 @@ func clearBloomBits(db ethdb.Database) {
|
||||||
|
|
||||||
func BenchmarkNoBloomBits(b *testing.B) {
|
func BenchmarkNoBloomBits(b *testing.B) {
|
||||||
benchDataDir := node.DefaultDataDir() + "/geth/chaindata"
|
benchDataDir := node.DefaultDataDir() + "/geth/chaindata"
|
||||||
fmt.Println("Running benchmark without bloombits")
|
b.Log("Running benchmark without bloombits")
|
||||||
db, err := rawdb.NewLevelDBDatabase(benchDataDir, 128, 1024, "")
|
db, err := rawdb.NewLevelDBDatabase(benchDataDir, 128, 1024, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("error opening database at %v: %v", benchDataDir, err)
|
b.Fatalf("error opening database at %v: %v", benchDataDir, err)
|
||||||
|
|
@ -171,14 +171,14 @@ func BenchmarkNoBloomBits(b *testing.B) {
|
||||||
|
|
||||||
clearBloomBits(db)
|
clearBloomBits(db)
|
||||||
|
|
||||||
fmt.Println("Running filter benchmarks...")
|
b.Log("Running filter benchmarks...")
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
mux := new(event.TypeMux)
|
mux := new(event.TypeMux)
|
||||||
backend := &testBackend{mux, db, 0, new(event.Feed), new(event.Feed), new(event.Feed), new(event.Feed)}
|
backend := &testBackend{mux, db, 0, new(event.Feed), new(event.Feed), new(event.Feed), new(event.Feed)}
|
||||||
filter := NewRangeFilter(backend, 0, int64(*headNum), []common.Address{{}}, nil)
|
filter := NewRangeFilter(backend, 0, int64(*headNum), []common.Address{{}}, nil)
|
||||||
filter.Logs(context.Background())
|
filter.Logs(context.Background())
|
||||||
d := time.Since(start)
|
d := time.Since(start)
|
||||||
fmt.Println("Finished running filter benchmarks")
|
b.Log("Finished running filter benchmarks")
|
||||||
fmt.Println(" ", d, "total ", d*time.Duration(1000000)/time.Duration(*headNum+1), "per million blocks")
|
b.Log(" ", d, "total ", d*time.Duration(1000000)/time.Duration(*headNum+1), "per million blocks")
|
||||||
db.Close()
|
db.Close()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue