go/list2/list_bench_test.go

52 lines
613 B
Go
Raw Normal View History

2014-09-13 13:00:14 +04:00
package list2
2014-04-17 05:23:44 +04:00
import (
"container/list"
"testing"
)
func BenchmarkGoList(b *testing.B) {
l := list.New()
n := 10000
for j := 0; j < b.N; j++ {
for i := 0; i < n; i++ {
l.PushBack(i)
}
for i := 0; i < n/2; i++ {
f := l.Front()
l.Remove(f)
}
for i := 0; i < n/2; i++ {
l.PushFront(i)
}
}
}
func BenchmarkList(b *testing.B) {
l := NewSize(10240)
b.ResetTimer()
n := 10000
for j := 0; j < b.N; j++ {
for i := 0; i < n; i++ {
l.PushBack(i)
}
for i := 0; i < n/2; i++ {
f := l.Front()
l.Remove(f)
}
for i := 0; i < n/2; i++ {
l.PushFront(i)
}
}
}