mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-03 10:32:05 +00:00
## Description Internalize some libs. This reduces the amount ot public API tendermint is supporting. The moved libraries are mainly ones that are used within Tendermint-core.
47 lines
771 B
Go
47 lines
771 B
Go
package clist
|
|
|
|
import "testing"
|
|
|
|
func BenchmarkDetaching(b *testing.B) {
|
|
lst := New()
|
|
for i := 0; i < b.N+1; i++ {
|
|
lst.PushBack(i)
|
|
}
|
|
start := lst.Front()
|
|
nxt := start.Next()
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
start.removed = true
|
|
start.DetachNext()
|
|
start.DetachPrev()
|
|
tmp := nxt
|
|
nxt = nxt.Next()
|
|
start = tmp
|
|
}
|
|
}
|
|
|
|
// This is used to benchmark the time of RMutex.
|
|
func BenchmarkRemoved(b *testing.B) {
|
|
lst := New()
|
|
for i := 0; i < b.N+1; i++ {
|
|
lst.PushBack(i)
|
|
}
|
|
start := lst.Front()
|
|
nxt := start.Next()
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
start.Removed()
|
|
tmp := nxt
|
|
nxt = nxt.Next()
|
|
start = tmp
|
|
}
|
|
}
|
|
|
|
func BenchmarkPushBack(b *testing.B) {
|
|
lst := New()
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
lst.PushBack(i)
|
|
}
|
|
}
|