File: segments_test.go

package info (click to toggle)
golang-github-gobwas-glob 0.2.3%2Bgit20180208.19c076c-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, buster-backports
  • size: 356 kB
  • sloc: sh: 20; makefile: 3
file content (83 lines) | stat: -rw-r--r-- 1,585 bytes parent folder | download | duplicates (4)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package match

import (
	"sync"
	"testing"
)

func benchPool(i int, b *testing.B) {
	pool := sync.Pool{New: func() interface{} {
		return make([]int, 0, i)
	}}

	b.RunParallel(func(pb *testing.PB) {
		for pb.Next() {
			s := pool.Get().([]int)[:0]
			pool.Put(s)
		}
	})
}

func benchMake(i int, b *testing.B) {
	b.RunParallel(func(pb *testing.PB) {
		for pb.Next() {
			_ = make([]int, 0, i)
		}
	})
}

func BenchmarkSegmentsPool_1(b *testing.B) {
	benchPool(1, b)
}
func BenchmarkSegmentsPool_2(b *testing.B) {
	benchPool(2, b)
}
func BenchmarkSegmentsPool_4(b *testing.B) {
	benchPool(4, b)
}
func BenchmarkSegmentsPool_8(b *testing.B) {
	benchPool(8, b)
}
func BenchmarkSegmentsPool_16(b *testing.B) {
	benchPool(16, b)
}
func BenchmarkSegmentsPool_32(b *testing.B) {
	benchPool(32, b)
}
func BenchmarkSegmentsPool_64(b *testing.B) {
	benchPool(64, b)
}
func BenchmarkSegmentsPool_128(b *testing.B) {
	benchPool(128, b)
}
func BenchmarkSegmentsPool_256(b *testing.B) {
	benchPool(256, b)
}

func BenchmarkSegmentsMake_1(b *testing.B) {
	benchMake(1, b)
}
func BenchmarkSegmentsMake_2(b *testing.B) {
	benchMake(2, b)
}
func BenchmarkSegmentsMake_4(b *testing.B) {
	benchMake(4, b)
}
func BenchmarkSegmentsMake_8(b *testing.B) {
	benchMake(8, b)
}
func BenchmarkSegmentsMake_16(b *testing.B) {
	benchMake(16, b)
}
func BenchmarkSegmentsMake_32(b *testing.B) {
	benchMake(32, b)
}
func BenchmarkSegmentsMake_64(b *testing.B) {
	benchMake(64, b)
}
func BenchmarkSegmentsMake_128(b *testing.B) {
	benchMake(128, b)
}
func BenchmarkSegmentsMake_256(b *testing.B) {
	benchMake(256, b)
}