Revision 9169ea28ac66181aea1cefcf8316a4c941955e6e authored by Thane Thomson on 22 December 2022, 14:22:32 UTC, committed by GitHub on 22 December 2022, 14:22:32 UTC
This reverts commit 5703cc3455c45acc8be3400a25cf21c09267e7c4.
1 parent 7379521
cache_bench_test.go
package mempool
import (
"encoding/binary"
"testing"
)
func BenchmarkCacheInsertTime(b *testing.B) {
cache := NewLRUTxCache(b.N)
txs := make([][]byte, b.N)
for i := 0; i < b.N; i++ {
txs[i] = make([]byte, 8)
binary.BigEndian.PutUint64(txs[i], uint64(i))
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
cache.Push(txs[i])
}
}
// This benchmark is probably skewed, since we actually will be removing
// txs in parallel, which may cause some overhead due to mutex locking.
func BenchmarkCacheRemoveTime(b *testing.B) {
cache := NewLRUTxCache(b.N)
txs := make([][]byte, b.N)
for i := 0; i < b.N; i++ {
txs[i] = make([]byte, 8)
binary.BigEndian.PutUint64(txs[i], uint64(i))
cache.Push(txs[i])
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
cache.Remove(txs[i])
}
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...