File: list_bench_test.go

package info (click to toggle)
golang-github-siddontang-go 0.0~git20170517.0.cb568a3-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 492 kB
  • sloc: makefile: 3
file content (51 lines) | stat: -rw-r--r-- 613 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package list2

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

	}
}