33import com .netflix .hystrix .strategy .properties .HystrixProperty ;
44import com .netflix .hystrix .util .HystrixRollingNumber ;
55import com .netflix .hystrix .util .HystrixRollingNumberEvent ;
6- import com .netflix .hystrix .util .HystrixRollingPercentile ;
76import org .openjdk .jmh .annotations .Benchmark ;
87import org .openjdk .jmh .annotations .BenchmarkMode ;
98import org .openjdk .jmh .annotations .Group ;
109import org .openjdk .jmh .annotations .GroupThreads ;
1110import org .openjdk .jmh .annotations .Level ;
1211import org .openjdk .jmh .annotations .Mode ;
1312import org .openjdk .jmh .annotations .OutputTimeUnit ;
14- import org .openjdk .jmh .annotations .Param ;
1513import org .openjdk .jmh .annotations .Scope ;
1614import org .openjdk .jmh .annotations .Setup ;
1715import org .openjdk .jmh .annotations .State ;
@@ -44,9 +42,15 @@ public void setUp() {
4442 value = r .nextInt (100 );
4543 int typeInt = r .nextInt (3 );
4644 switch (typeInt ) {
47- case 0 : type = HystrixRollingNumberEvent .SUCCESS ;
48- case 1 : type = HystrixRollingNumberEvent .FAILURE ;
49- case 2 : type = HystrixRollingNumberEvent .COMMAND_MAX_ACTIVE ;
45+ case 0 :
46+ type = HystrixRollingNumberEvent .SUCCESS ;
47+ break ;
48+ case 1 :
49+ type = HystrixRollingNumberEvent .FAILURE ;
50+ break ;
51+ case 2 :
52+ type = HystrixRollingNumberEvent .TIMEOUT ;
53+ break ;
5054 default : throw new RuntimeException ("Unexpected : " + typeInt );
5155 }
5256 }
@@ -67,17 +71,18 @@ public long readOnly(CounterState counterState) {
6771 HystrixRollingNumber counter = counterState .counter ;
6872 return counter .getCumulativeSum (HystrixRollingNumberEvent .SUCCESS ) +
6973 counter .getCumulativeSum (HystrixRollingNumberEvent .FAILURE ) +
70- counter .getRollingMaxValue (HystrixRollingNumberEvent .COMMAND_MAX_ACTIVE ) +
74+ counter .getCumulativeSum (HystrixRollingNumberEvent .TIMEOUT ) +
7175 counter .getRollingSum (HystrixRollingNumberEvent .SUCCESS ) +
72- counter .getRollingSum (HystrixRollingNumberEvent .FAILURE );
76+ counter .getRollingSum (HystrixRollingNumberEvent .FAILURE ) +
77+ counter .getRollingSum (HystrixRollingNumberEvent .TIMEOUT );
7378 }
7479
7580 @ Benchmark
7681 @ Group ("writeHeavy" )
7782 @ GroupThreads (7 )
7883 @ BenchmarkMode ({Mode .Throughput })
7984 @ OutputTimeUnit (TimeUnit .MILLISECONDS )
80- public HystrixRollingNumber writeHeavyLatencyAdd (CounterState counterState , ValueState valueState ) {
85+ public HystrixRollingNumber writeHeavyCounterAdd (CounterState counterState , ValueState valueState ) {
8186 counterState .counter .add (valueState .type , valueState .value );
8287 return counterState .counter ;
8388 }
@@ -91,17 +96,18 @@ public long writeHeavyReadMetrics(CounterState counterState) {
9196 HystrixRollingNumber counter = counterState .counter ;
9297 return counter .getCumulativeSum (HystrixRollingNumberEvent .SUCCESS ) +
9398 counter .getCumulativeSum (HystrixRollingNumberEvent .FAILURE ) +
94- counter .getRollingMaxValue (HystrixRollingNumberEvent .COMMAND_MAX_ACTIVE ) +
99+ counter .getCumulativeSum (HystrixRollingNumberEvent .TIMEOUT ) +
95100 counter .getRollingSum (HystrixRollingNumberEvent .SUCCESS ) +
96- counter .getRollingSum (HystrixRollingNumberEvent .FAILURE );
101+ counter .getRollingSum (HystrixRollingNumberEvent .FAILURE ) +
102+ counter .getRollingSum (HystrixRollingNumberEvent .TIMEOUT );
97103 }
98104
99105 @ Benchmark
100106 @ Group ("evenSplit" )
101107 @ GroupThreads (4 )
102108 @ BenchmarkMode ({Mode .Throughput })
103109 @ OutputTimeUnit (TimeUnit .MILLISECONDS )
104- public HystrixRollingNumber evenSplitLatencyAdd (CounterState counterState , ValueState valueState ) {
110+ public HystrixRollingNumber evenSplitCounterAdd (CounterState counterState , ValueState valueState ) {
105111 counterState .counter .add (valueState .type , valueState .value );
106112 return counterState .counter ;
107113 }
@@ -115,17 +121,18 @@ public long evenSplitReadMetrics(CounterState counterState) {
115121 HystrixRollingNumber counter = counterState .counter ;
116122 return counter .getCumulativeSum (HystrixRollingNumberEvent .SUCCESS ) +
117123 counter .getCumulativeSum (HystrixRollingNumberEvent .FAILURE ) +
118- counter .getRollingMaxValue (HystrixRollingNumberEvent .COMMAND_MAX_ACTIVE ) +
124+ counter .getCumulativeSum (HystrixRollingNumberEvent .TIMEOUT ) +
119125 counter .getRollingSum (HystrixRollingNumberEvent .SUCCESS ) +
120- counter .getRollingSum (HystrixRollingNumberEvent .FAILURE );
126+ counter .getRollingSum (HystrixRollingNumberEvent .FAILURE ) +
127+ counter .getRollingSum (HystrixRollingNumberEvent .TIMEOUT );
121128 }
122129
123130 @ Benchmark
124131 @ Group ("readHeavy" )
125132 @ GroupThreads (1 )
126133 @ BenchmarkMode ({Mode .Throughput })
127134 @ OutputTimeUnit (TimeUnit .MILLISECONDS )
128- public HystrixRollingNumber readHeavyLatencyAdd (CounterState counterState , ValueState valueState ) {
135+ public HystrixRollingNumber readHeavyCounterAdd (CounterState counterState , ValueState valueState ) {
129136 counterState .counter .add (valueState .type , valueState .value );
130137 return counterState .counter ;
131138 }
@@ -139,8 +146,9 @@ public long readHeavyReadMetrics(CounterState counterState) {
139146 HystrixRollingNumber counter = counterState .counter ;
140147 return counter .getCumulativeSum (HystrixRollingNumberEvent .SUCCESS ) +
141148 counter .getCumulativeSum (HystrixRollingNumberEvent .FAILURE ) +
142- counter .getRollingMaxValue (HystrixRollingNumberEvent .COMMAND_MAX_ACTIVE ) +
149+ counter .getCumulativeSum (HystrixRollingNumberEvent .TIMEOUT ) +
143150 counter .getRollingSum (HystrixRollingNumberEvent .SUCCESS ) +
144- counter .getRollingSum (HystrixRollingNumberEvent .FAILURE );
151+ counter .getRollingSum (HystrixRollingNumberEvent .FAILURE ) +
152+ counter .getRollingSum (HystrixRollingNumberEvent .TIMEOUT );
145153 }
146154}
0 commit comments