@@ -8,10 +8,14 @@ public class Recording32BitBenchmark
88 {
99 private readonly long [ ] _testValues ;
1010 private readonly LongHistogram _longHistogram ;
11+ private readonly LongConcurrentHistogram _longConcurrentHistogram ;
1112 private readonly IntHistogram _intHistogram ;
13+ private readonly IntConcurrentHistogram _intConcurrentHistogram ;
1214 private readonly ShortHistogram _shortHistogram ;
1315 private readonly Recorder _longRecorder ;
16+ private readonly Recorder _longConcurrentRecorder ;
1417 private readonly Recorder _intRecorder ;
18+ private readonly Recorder _intConcurrentRecorder ;
1519 private readonly Recorder _shortRecorder ;
1620
1721 public Recording32BitBenchmark ( )
@@ -27,16 +31,21 @@ public Recording32BitBenchmark()
2731 x . Value + 1 ,
2832 } )
2933 . Where ( x => x > 0 )
30- . Where ( x=> x < highestTrackableValue )
34+ . Where ( x => x < highestTrackableValue )
3135 . Distinct ( )
3236 . ToArray ( ) ;
3337
3438 _longHistogram = new LongHistogram ( highestTrackableValue , 3 ) ;
3539 _intHistogram = new IntHistogram ( highestTrackableValue , 3 ) ;
3640 _shortHistogram = new ShortHistogram ( highestTrackableValue , 3 ) ;
3741
42+ _longConcurrentHistogram = new LongConcurrentHistogram ( 1 , highestTrackableValue , 3 ) ;
43+ _intConcurrentHistogram = new IntConcurrentHistogram ( 1 , highestTrackableValue , 3 ) ;
44+
3845 _longRecorder = new Recorder ( 1 , highestTrackableValue , 3 , ( id , low , hi , sf ) => new LongHistogram ( id , low , hi , sf ) ) ;
46+ _longConcurrentRecorder = new Recorder ( 1 , highestTrackableValue , 3 , ( id , low , hi , sf ) => new LongConcurrentHistogram ( id , low , hi , sf ) ) ;
3947 _intRecorder = new Recorder ( 1 , highestTrackableValue , 3 , ( id , low , hi , sf ) => new IntHistogram ( id , low , hi , sf ) ) ;
48+ _intConcurrentRecorder = new Recorder ( 1 , highestTrackableValue , 3 , ( id , low , hi , sf ) => new IntConcurrentHistogram ( id , low , hi , sf ) ) ;
4049 _shortRecorder = new Recorder ( 1 , highestTrackableValue , 3 , ( id , low , hi , sf ) => new ShortHistogram ( id , low , hi , sf ) ) ;
4150 }
4251
@@ -53,6 +62,19 @@ public long LongHistogramRecording()
5362 return counter ;
5463 }
5564
65+ [ Benchmark ]
66+ public long LongConcurrentHistogramRecording ( )
67+ {
68+ long counter = 0L ;
69+ for ( int i = 0 ; i < _testValues . Length ; i ++ )
70+ {
71+ var value = _testValues [ i ] ;
72+ _longConcurrentHistogram . RecordValue ( value ) ;
73+ counter += value ;
74+ }
75+ return counter ;
76+ }
77+
5678 [ Benchmark ]
5779 public long IntHistogramRecording ( )
5880 {
@@ -66,6 +88,19 @@ public long IntHistogramRecording()
6688 return counter ;
6789 }
6890
91+ [ Benchmark ]
92+ public long IntConcurrentHistogramRecording ( )
93+ {
94+ long counter = 0L ;
95+ for ( int i = 0 ; i < _testValues . Length ; i ++ )
96+ {
97+ var value = _testValues [ i ] ;
98+ _intConcurrentHistogram . RecordValue ( value ) ;
99+ counter += value ;
100+ }
101+ return counter ;
102+ }
103+
69104 [ Benchmark ]
70105 public long ShortHistogramRecording ( )
71106 {
@@ -90,6 +125,20 @@ public long LongRecorderRecording()
90125 return counter ;
91126 }
92127
128+ [ Benchmark ]
129+ public long LongConcurrentRecorderRecording ( )
130+ {
131+ long counter = 0L ;
132+
133+ for ( int i = 0 ; i < _testValues . Length ; i ++ )
134+ {
135+ var value = _testValues [ i ] ;
136+ _longConcurrentRecorder . RecordValue ( value ) ;
137+ counter += value ;
138+ }
139+ return counter ;
140+ }
141+
93142 [ Benchmark ]
94143 public long IntRecorderRecording ( )
95144 {
@@ -103,6 +152,19 @@ public long IntRecorderRecording()
103152 return counter ;
104153 }
105154
155+ [ Benchmark ]
156+ public long IntConcurrentRecorderRecording ( )
157+ {
158+ long counter = 0L ;
159+ for ( int i = 0 ; i < _testValues . Length ; i ++ )
160+ {
161+ var value = _testValues [ i ] ;
162+ _intConcurrentRecorder . RecordValue ( value ) ;
163+ counter += value ;
164+ }
165+ return counter ;
166+ }
167+
106168 [ Benchmark ]
107169 public long ShortRecorderRecording ( )
108170 {
0 commit comments