mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 05:06:43 +00:00
core: using testing.B.Loop
This commit is contained in:
parent
6492751355
commit
5adf9dced1
2 changed files with 5 additions and 6 deletions
|
|
@ -301,7 +301,7 @@ func makeChainForBench(db ethdb.Database, genesis *Genesis, full bool, count uin
|
||||||
|
|
||||||
func benchWriteChain(b *testing.B, full bool, count uint64) {
|
func benchWriteChain(b *testing.B, full bool, count uint64) {
|
||||||
genesis := &Genesis{Config: params.AllEthashProtocolChanges}
|
genesis := &Genesis{Config: params.AllEthashProtocolChanges}
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
pdb, err := pebble.New(b.TempDir(), 1024, 128, "", false)
|
pdb, err := pebble.New(b.TempDir(), 1024, 128, "", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("error opening database: %v", err)
|
b.Fatalf("error opening database: %v", err)
|
||||||
|
|
@ -327,8 +327,7 @@ func benchReadChain(b *testing.B, full bool, count uint64) {
|
||||||
options := DefaultConfig().WithArchive(true)
|
options := DefaultConfig().WithArchive(true)
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
|
for b.Loop() {
|
||||||
for i := 0; i < b.N; i++ {
|
|
||||||
pdb, err = pebble.New(dir, 1024, 128, "", false)
|
pdb, err = pebble.New(dir, 1024, 128, "", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("error opening database: %v", err)
|
b.Fatalf("error opening database: %v", err)
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ func BenchmarkHashing(b *testing.B) {
|
||||||
var hasher = sha3.NewLegacyKeccak256()
|
var hasher = sha3.NewLegacyKeccak256()
|
||||||
b.Run("iteratorhashing", func(b *testing.B) {
|
b.Run("iteratorhashing", func(b *testing.B) {
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
var hash common.Hash
|
var hash common.Hash
|
||||||
it, err := rlp.NewListIterator(bodyRlp)
|
it, err := rlp.NewListIterator(bodyRlp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -173,7 +173,7 @@ func BenchmarkHashing(b *testing.B) {
|
||||||
var exp common.Hash
|
var exp common.Hash
|
||||||
b.Run("fullbodyhashing", func(b *testing.B) {
|
b.Run("fullbodyhashing", func(b *testing.B) {
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
var body types.Body
|
var body types.Body
|
||||||
rlp.DecodeBytes(bodyRlp, &body)
|
rlp.DecodeBytes(bodyRlp, &body)
|
||||||
for _, tx := range body.Transactions {
|
for _, tx := range body.Transactions {
|
||||||
|
|
@ -183,7 +183,7 @@ func BenchmarkHashing(b *testing.B) {
|
||||||
})
|
})
|
||||||
b.Run("fullblockhashing", func(b *testing.B) {
|
b.Run("fullblockhashing", func(b *testing.B) {
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
var block types.Block
|
var block types.Block
|
||||||
rlp.DecodeBytes(blockRlp, &block)
|
rlp.DecodeBytes(blockRlp, &block)
|
||||||
for _, tx := range block.Transactions() {
|
for _, tx := range block.Transactions() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue