diff --git a/list/list_bench_test.go b/list/list_bench_test.go new file mode 100644 index 0000000..8736f31 --- /dev/null +++ b/list/list_bench_test.go @@ -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) + } + + } +}