core: add better benchmark numbers

This commit is contained in:
Marius van der Wijden 2024-10-15 11:04:05 +02:00
parent 56011b6d87
commit 99c0c1818a
2 changed files with 7 additions and 7 deletions

View file

@ -2273,9 +2273,9 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error {
// reads should be blocked until the mutation is complete.
bc.txLookupLock.Lock()
var stats runtime.MemStats
runtime.ReadMemStats(&stats)
panic(stats.HeapInuse)
//var stats runtime.MemStats
//runtime.ReadMemStats(&stats)
//panic(stats.HeapInuse)
// Insert the new chain segment in incremental order, from the old
// to the new. The new chain head (newChain[0]) is not inserted here,

View file

@ -4249,8 +4249,8 @@ func BenchmarkReorg(b *testing.B) {
defer blockchain.Stop()
// Insert an easy and a difficult chain afterwards
easyBlocks, _ := GenerateChain(params.TestChainConfig, blockchain.GetBlockByHash(blockchain.CurrentBlock().Hash()), ethash.NewFaker(), db, chainLength, genValueTx(500))
diffBlocks, _ := GenerateChain(params.TestChainConfig, blockchain.GetBlockByHash(blockchain.CurrentBlock().Hash()), ethash.NewFaker(), db, chainLength, genValueTx(500))
easyBlocks, _ := GenerateChain(params.TestChainConfig, blockchain.GetBlockByHash(blockchain.CurrentBlock().Hash()), ethash.NewFaker(), db, chainLength, genValueTx(50000))
diffBlocks, _ := GenerateChain(params.TestChainConfig, blockchain.GetBlockByHash(blockchain.CurrentBlock().Hash()), ethash.NewFaker(), db, chainLength, genValueTx(50000))
if _, err := blockchain.InsertChain(easyBlocks); err != nil {
b.Fatalf("failed to insert easy chain: %v", err)
@ -4261,5 +4261,5 @@ func BenchmarkReorg(b *testing.B) {
}
}
// BenchmarkReorg-8 10000 362204 ns/op 271290 B/op 1256 allocs/op 151412736 bytes of heap used
// BenchmarkReorg-8 10000 381835 ns/op 276959 B/op 1324 allocs/op 152895488 bytes of heap used
// Master: BenchmarkReorg-8 10000 899591 ns/op 820154 B/op 1440 allocs/op 1549443072 bytes of heap used
// WithoutOldChain: BenchmarkReorg-8 10000 1147281 ns/op 943163 B/op 1564 allocs/op 1163870208 bytes of heap used