add bench test

This commit is contained in:
siddontang 2014-04-17 09:23:44 +08:00
parent eb8269b44c
commit 0a9ad31602
1 changed files with 51 additions and 0 deletions

51
list/list_bench_test.go Normal file
View File

@ -0,0 +1,51 @@
package list
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)
}
}
}