55using BenchmarkDotNet . Running ;
66using CHttpServer . Http3 ;
77
8- BenchmarkRunner . Run < IntegerDecoderBenchmarks > ( ) ;
8+ BenchmarkSwitcher . FromAssembly ( typeof ( Program ) . Assembly ) . Run ( args ) ;
99
1010[ SimpleJob ]
11- public class IntegerDecoderComparisonBenchmarks
11+ public class PrefixedIntegerDecoderBenchmarks
1212{
1313 /// <summary>
1414 /// 2147483647, 167321, 1433, 31, 1073741950
@@ -21,19 +21,8 @@ public class IntegerDecoderComparisonBenchmarks
2121 [ 0b01111111 , 0b11111111 , 0b11111111 , 0b11111111 , 0b11111111 , 0b00000011 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ]
2222 ] ;
2323
24- public static byte [ ] [ ] InputVariableSource { get ; } = [
25- [ 0b11000000 , 0b00000000 , 0b00000000 , 0b00000000 , 0b01111111 , 0b11111111 , 0b11111111 , 0b11111111 ] ,
26- [ 0b10000000 , 0b00000010 , 0b10001101 , 0b10011001 ] ,
27- [ 0b01000101 , 0b10011001 ] ,
28- [ 0b00011111 ] ,
29- [ 0b11000000 , 0b00000000 , 0b00000000 , 0b00000000 , 0b01000000 , 0b00000000 , 0b00000000 , 0b01111110 ]
30- ] ;
31-
3224 [ ParamsSource ( nameof ( InputPrefixedSource ) ) ]
33- public static byte [ ] _inputPrefixed ;
34-
35- [ ParamsSource ( nameof ( InputVariableSource ) ) ]
36- public byte [ ] _inputVariable ;
25+ public static byte [ ] _inputPrefixed = [ ] ;
3726
3827 [ Benchmark ]
3928 public int DecodeIntegerSimd ( )
@@ -56,6 +45,24 @@ public int DecodeInteger()
5645 decoder . TryDecodeInteger ( _inputPrefixed , ref index , out result ) ;
5746 return result ;
5847 }
48+ }
49+
50+ [ SimpleJob ]
51+ public class VariableLengthIntegerDecoderBenchmarks
52+ {
53+ /// <summary>
54+ /// 2147483647, 167321, 1433, 31, 1073741950
55+ /// </summary>
56+ public static byte [ ] [ ] InputVariableSource { get ; } = [
57+ [ 0b11000000 , 0b00000000 , 0b00000000 , 0b00000000 , 0b01111111 , 0b11111111 , 0b11111111 , 0b11111111 ] ,
58+ [ 0b10000000 , 0b00000010 , 0b10001101 , 0b10011001 ] ,
59+ [ 0b01000101 , 0b10011001 ] ,
60+ [ 0b00011111 ] ,
61+ [ 0b11000000 , 0b00000000 , 0b00000000 , 0b00000000 , 0b01000000 , 0b00000000 , 0b00000000 , 0b01111110 ]
62+ ] ;
63+
64+ [ ParamsSource ( nameof ( InputVariableSource ) ) ]
65+ public byte [ ] _inputVariable = [ ] ;
5966
6067 [ Benchmark ]
6168 public int DecodeIntegerVariable ( )
0 commit comments