You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

46 lines
771 B

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)
}
}