@@ -48,7 +48,33 @@ func BenchmarkCounterParallel(b *testing.B) {
48
48
benchmarkCounterParallel (b , "Uint64.Set" , NewSet ().NewUint64 , (* Uint64 ).Set , 1 )
49
49
benchmarkCounterParallel (b , "Float64.Add" , NewSet ().NewFloat64 , (* Float64 ).Add , 1 )
50
50
benchmarkCounterParallel (b , "Float64.Set" , NewSet ().NewFloat64 , (* Float64 ).Set , 1 )
51
- benchmarkCounterParallel (b , "Histogram.Update" , NewSet ().NewHistogram , (* Histogram ).Update , 1 )
51
+ benchmarkCounterParallel (b , "Histogram.Update int" , NewSet ().NewHistogram , (* Histogram ).Update , 1 )
52
+ benchmarkCounterParallel (b , "Histogram.Update float" , NewSet ().NewHistogram , (* Histogram ).Update , 1.3 )
53
+ }
54
+
55
+ func BenchmarkCounterSerial (b * testing.B ) {
56
+ benchmarkCounter (b , "Uint64.Add" , NewSet ().NewUint64 , (* Uint64 ).Add , 1 )
57
+ benchmarkCounter (b , "Uint64.Set" , NewSet ().NewUint64 , (* Uint64 ).Set , 1 )
58
+ benchmarkCounter (b , "Float64.Add" , NewSet ().NewFloat64 , (* Float64 ).Add , 1 )
59
+ benchmarkCounter (b , "Float64.Set" , NewSet ().NewFloat64 , (* Float64 ).Set , 1 )
60
+ benchmarkCounter (b , "Histogram.Update int" , NewSet ().NewHistogram , (* Histogram ).Update , 1 )
61
+ benchmarkCounter (b , "Histogram.Update float" , NewSet ().NewHistogram , (* Histogram ).Update , 1.3 )
62
+ }
63
+
64
+ func benchmarkCounter [T any , V any ](
65
+ b * testing.B ,
66
+ name string ,
67
+ setup func (string , ... string ) * T ,
68
+ do func (* T , V ),
69
+ value V ,
70
+ ) {
71
+ b .Helper ()
72
+ thing := setup ("foo" )
73
+ b .Run (name , func (b * testing.B ) {
74
+ for b .Loop () {
75
+ do (thing , value )
76
+ }
77
+ })
52
78
}
53
79
54
80
func benchmarkCounterParallel [T any , V any ](
@@ -61,7 +87,6 @@ func benchmarkCounterParallel[T any, V any](
61
87
b .Helper ()
62
88
thing := setup ("foo" )
63
89
b .Run (name , func (b * testing.B ) {
64
- b .ReportAllocs ()
65
90
b .RunParallel (func (pb * testing.PB ) {
66
91
for pb .Next () {
67
92
do (thing , value )
0 commit comments