From 0a9ad3160244748fb5677817b49945f8d2ebb7f0 Mon Sep 17 00:00:00 2001 From: siddontang Date: Thu, 17 Apr 2014 09:23:44 +0800 Subject: [PATCH] add bench test --- list/list_bench_test.go | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 list/list_bench_test.go 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) + } + + } +}