@@ -20,9 +20,39 @@ public class Recording32BitBenchmark
2020
2121 public Recording32BitBenchmark ( )
2222 {
23- //Create array of +ve numbers in the 'maxBit' bit range (i.e. 32 bit or 64bit)
23+ const int lowestTrackableValue = 1 ;
2424 var highestTrackableValue = TimeStamp . Minutes ( 10 ) ;
25- _testValues = Enumerable . Range ( 0 , 32 )
25+ const int numberOfSignificantValueDigits = 3 ;
26+
27+ _testValues = TestValues ( highestTrackableValue ) ;
28+
29+ _longHistogram = new LongHistogram ( highestTrackableValue , numberOfSignificantValueDigits ) ;
30+ _intHistogram = new IntHistogram ( highestTrackableValue , numberOfSignificantValueDigits ) ;
31+ _shortHistogram = new ShortHistogram ( highestTrackableValue , numberOfSignificantValueDigits ) ;
32+
33+ _longConcurrentHistogram = new LongConcurrentHistogram ( lowestTrackableValue , highestTrackableValue , numberOfSignificantValueDigits ) ;
34+ _intConcurrentHistogram = new IntConcurrentHistogram ( lowestTrackableValue , highestTrackableValue , numberOfSignificantValueDigits ) ;
35+
36+ _longRecorder = new Recorder ( lowestTrackableValue , highestTrackableValue , numberOfSignificantValueDigits , ( id , low , hi , sf ) => new LongHistogram ( id , low , hi , sf ) ) ;
37+ _longConcurrentRecorder = new Recorder ( lowestTrackableValue , highestTrackableValue , numberOfSignificantValueDigits , ( id , low , hi , sf ) => new LongConcurrentHistogram ( id , low , hi , sf ) ) ;
38+ _intRecorder = new Recorder ( lowestTrackableValue , highestTrackableValue , numberOfSignificantValueDigits , ( id , low , hi , sf ) => new IntHistogram ( id , low , hi , sf ) ) ;
39+ _intConcurrentRecorder = new Recorder ( lowestTrackableValue , highestTrackableValue , numberOfSignificantValueDigits , ( id , low , hi , sf ) => new IntConcurrentHistogram ( id , low , hi , sf ) ) ;
40+ _shortRecorder = new Recorder ( lowestTrackableValue , highestTrackableValue , numberOfSignificantValueDigits , ( id , low , hi , sf ) => new ShortHistogram ( id , low , hi , sf ) ) ;
41+ }
42+
43+ private static long [ ] TestValues ( long highestTrackableValue )
44+ {
45+ //Create array of +ve numbers in the 'maxBit' bit range (i.e. 32 bit or 64bit)
46+ // 32 bit values are the 89 values
47+ // 1,2,3,4,5,7,8,9,15,16,17,31,32,33,63,64,65,127,128,129,255,256,257,511,512,513,1023,1024,1025,2047,2048,2049,4095,4096,4097,8191,8192,8193,
48+ // 16383,16384,16385,32767,32768,32769,65535,65536,65537,131071,131072,131073,262143,262144,262145,524287,524288,524289,1048575,1048576,1048577,
49+ // 2097151,2097152,2097153,4194303,4194304,4194305,8388607,8388608,8388609,16777215,16777216,16777217,33554431,33554432,33554433,
50+ // 67108863,67108864,67108865,134217727,134217728,134217729,268435455,268435456,268435457,536870911,536870912,536870913,1073741823,1073741824,1073741825
51+ //These value are choosen as they are the edge case values of where our bucket boundaries lie. i.e.
52+ // a power of 2
53+ // 1 less than a power of 2
54+ // 1 more than a power of 2
55+ return Enumerable . Range ( 0 , 32 )
2656 . Select ( exp => new { Value = 1L << exp , LZC = 63 - exp } )
2757 . SelectMany ( x => new [ ]
2858 {
@@ -34,19 +64,6 @@ public Recording32BitBenchmark()
3464 . Where ( x => x < highestTrackableValue )
3565 . Distinct ( )
3666 . ToArray ( ) ;
37-
38- _longHistogram = new LongHistogram ( highestTrackableValue , 3 ) ;
39- _intHistogram = new IntHistogram ( highestTrackableValue , 3 ) ;
40- _shortHistogram = new ShortHistogram ( highestTrackableValue , 3 ) ;
41-
42- _longConcurrentHistogram = new LongConcurrentHistogram ( 1 , highestTrackableValue , 3 ) ;
43- _intConcurrentHistogram = new IntConcurrentHistogram ( 1 , highestTrackableValue , 3 ) ;
44-
45- _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 ) ) ;
47- _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 ) ) ;
49- _shortRecorder = new Recorder ( 1 , highestTrackableValue , 3 , ( id , low , hi , sf ) => new ShortHistogram ( id , low , hi , sf ) ) ;
5067 }
5168
5269 [ Benchmark ( Baseline = true ) ]
0 commit comments