@@ -31,8 +31,10 @@ func BenchmarkBufferPool(b *testing.B) {
31
31
)
32
32
}
33
33
run ("default/8" , func (tb * testing.B ) {
34
- e := chanque .NewExecutor (10 , 10 )
35
- defer e .Release ()
34
+ tb .StopTimer ()
35
+ e := chanque .NewExecutor (100 , 100 )
36
+ tb .Cleanup (func () { e .Release () })
37
+ tb .StartTimer ()
36
38
37
39
for i := 0 ; i < tb .N ; i += 1 {
38
40
e .Submit (func () {
@@ -42,8 +44,10 @@ func BenchmarkBufferPool(b *testing.B) {
42
44
}
43
45
})
44
46
run ("default/4096" , func (tb * testing.B ) {
45
- e := chanque .NewExecutor (10 , 10 )
46
- defer e .Release ()
47
+ tb .StopTimer ()
48
+ e := chanque .NewExecutor (100 , 100 )
49
+ tb .Cleanup (func () { e .Release () })
50
+ tb .StartTimer ()
47
51
48
52
for i := 0 ; i < tb .N ; i += 1 {
49
53
e .Submit (func () {
@@ -53,8 +57,10 @@ func BenchmarkBufferPool(b *testing.B) {
53
57
}
54
58
})
55
59
run ("syncpool/8" , func (tb * testing.B ) {
56
- e := chanque .NewExecutor (10 , 10 )
57
- defer e .Release ()
60
+ tb .StopTimer ()
61
+ e := chanque .NewExecutor (100 , 100 )
62
+ tb .Cleanup (func () { e .Release () })
63
+ tb .StartTimer ()
58
64
59
65
p := & sync.Pool {
60
66
New : func () interface {} {
@@ -71,8 +77,10 @@ func BenchmarkBufferPool(b *testing.B) {
71
77
}
72
78
})
73
79
run ("syncpool/4096" , func (tb * testing.B ) {
74
- e := chanque .NewExecutor (10 , 10 )
75
- defer e .Release ()
80
+ tb .StopTimer ()
81
+ e := chanque .NewExecutor (100 , 100 )
82
+ tb .Cleanup (func () { e .Release () })
83
+ tb .StartTimer ()
76
84
77
85
p := & sync.Pool {
78
86
New : func () interface {} {
@@ -89,8 +97,10 @@ func BenchmarkBufferPool(b *testing.B) {
89
97
}
90
98
})
91
99
run ("bufferpool/8" , func (tb * testing.B ) {
92
- e := chanque .NewExecutor (10 , 10 )
93
- defer e .Release ()
100
+ tb .StopTimer ()
101
+ e := chanque .NewExecutor (100 , 100 )
102
+ tb .Cleanup (func () { e .Release () })
103
+ tb .StartTimer ()
94
104
95
105
p := NewBufferPool (e .MaxWorker (), 8 )
96
106
@@ -103,8 +113,10 @@ func BenchmarkBufferPool(b *testing.B) {
103
113
}
104
114
})
105
115
run ("bufferpool/4096" , func (tb * testing.B ) {
106
- e := chanque .NewExecutor (10 , 10 )
107
- defer e .Release ()
116
+ tb .StopTimer ()
117
+ e := chanque .NewExecutor (100 , 100 )
118
+ tb .Cleanup (func () { e .Release () })
119
+ tb .StartTimer ()
108
120
109
121
p := NewBufferPool (e .MaxWorker (), 4096 )
110
122
0 commit comments