jeqo commented on code in PR #13177:
URL: https://github.com/apache/kafka/pull/13177#discussion_r1096076032


##########
jmh-benchmarks/src/main/java/org/apache/kafka/jmh/common/metrics/SensorBenchmark.java:
##########
@@ -0,0 +1,145 @@
+package org.apache.kafka.jmh.common.metrics;
+
+import org.apache.kafka.common.metrics.Metrics;
+import org.apache.kafka.common.metrics.Sensor;
+import org.apache.kafka.common.metrics.stats.Avg;
+import org.apache.kafka.common.metrics.stats.Max;
+import org.apache.kafka.common.metrics.stats.Min;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+@State(Scope.Benchmark)
+@Fork(value = 1)
+@Warmup(iterations = 5)
+@Measurement(iterations = 5)
+@BenchmarkMode(Mode.AverageTime)

Review Comment:
   Sure! I have added SampleTime, and got some interesting stats:
   
   ```
   Benchmark                                                                    
          (numSensors)    Mode      Cnt        Score      Error  Units
   SensorBenchmark.recordBenchmark                                              
                     1    avgt        4      122.285 ±    3.831  ns/op
   SensorBenchmark.recordBenchmark                                              
                     5    avgt        4      535.055 ±   10.002  ns/op
   SensorBenchmark.recordBenchmark                                              
                    20    avgt        4     2153.720 ±  562.511  ns/op
   SensorBenchmark.recordWithAvgBenchmark                                       
                     1    avgt        4      148.655 ±    7.245  ns/op
   SensorBenchmark.recordWithAvgBenchmark                                       
                     5    avgt        4      801.836 ±   25.243  ns/op
   SensorBenchmark.recordWithAvgBenchmark                                       
                    20    avgt        4     5934.782 ±  463.325  ns/op
   SensorBenchmark.recordWithMaxAvgBenchmark                                    
                     1    avgt        4      153.731 ±    8.982  ns/op
   SensorBenchmark.recordWithMaxAvgBenchmark                                    
                     5    avgt        4     1067.862 ±   68.656  ns/op
   SensorBenchmark.recordWithMaxAvgBenchmark                                    
                    20    avgt        4    10486.323 ±  209.097  ns/op
   SensorBenchmark.recordWithMaxBenchmark                                       
                     1    avgt        4      148.492 ±   20.097  ns/op
   SensorBenchmark.recordWithMaxBenchmark                                       
                     5    avgt        4      807.746 ±  300.785  ns/op
   SensorBenchmark.recordWithMaxBenchmark                                       
                    20    avgt        4     6361.096 ± 1160.907  ns/op
   SensorBenchmark.recordWithMinMaxAvgBenchmark                                 
                     1    avgt        4      178.676 ±   12.371  ns/op
   SensorBenchmark.recordWithMinMaxAvgBenchmark                                 
                     5    avgt        4     1749.455 ±  204.069  ns/op
   SensorBenchmark.recordWithMinMaxAvgBenchmark                                 
                    20    avgt        4    25027.613 ± 1407.740  ns/op
   SensorBenchmark.recordWithMinMaxBenchmark                                    
                     1    avgt        4      158.032 ±    9.249  ns/op
   SensorBenchmark.recordWithMinMaxBenchmark                                    
                     5    avgt        4     1001.310 ±   48.258  ns/op
   SensorBenchmark.recordWithMinMaxBenchmark                                    
                    20    avgt        4     8958.896 ±  264.169  ns/op
   SensorBenchmark.recordWithPercentileBenchmark                                
                     1    avgt        4      133.637 ±    7.675  ns/op
   SensorBenchmark.recordWithPercentileBenchmark                                
                     5    avgt        4      766.876 ±   14.212  ns/op
   SensorBenchmark.recordWithPercentileBenchmark                                
                    20    avgt        4     5661.163 ±  463.749  ns/op
   SensorBenchmark.recordWithWindowedSumBenchmark                               
                     1    avgt        4      119.896 ±   13.392  ns/op
   SensorBenchmark.recordWithWindowedSumBenchmark                               
                     5    avgt        4      663.232 ±    9.704  ns/op
   SensorBenchmark.recordWithWindowedSumBenchmark                               
                    20    avgt        4     4976.913 ±  430.296  ns/op
   SensorBenchmark.recordBenchmark                                              
                     1  sample  1306062      176.717 ±    2.809  ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.00                        
                     1  sample                92.000             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.50                        
                     1  sample               135.000             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.90                        
                     1  sample               150.000             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.95                        
                     1  sample               156.000             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.99                        
                     1  sample               181.000             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.999                       
                     1  sample             19325.984             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.9999                      
                     1  sample             32108.598             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p1.00                        
                     1  sample            195328.000             ns/op
   SensorBenchmark.recordBenchmark                                              
                     5  sample  1023159      694.906 ±    7.662  ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.00                        
                     5  sample               455.000             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.50                        
                     5  sample               565.000             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.90                        
                     5  sample               780.000             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.95                        
                     5  sample               847.000             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.99                        
                     5  sample              1214.000             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.999                       
                     5  sample             24192.000             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.9999                      
                     5  sample             60338.432             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p1.00                        
                     5  sample            716800.000             ns/op
   SensorBenchmark.recordBenchmark                                              
                    20  sample  1271143     2011.945 ±    7.842  ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.00                        
                    20  sample              1610.000             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.50                        
                    20  sample              1750.000             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.90                        
                    20  sample              2100.000             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.95                        
                    20  sample              2892.000             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.99                        
                    20  sample              3616.000             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.999                       
                    20  sample             28576.000             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p0.9999                      
                    20  sample             77425.357             ns/op
   SensorBenchmark.recordBenchmark:recordBenchmark·p1.00                        
                    20  sample           1118208.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark                                       
                     1  sample  1262271      179.238 ±   13.287  ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.00          
                     1  sample               102.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.50          
                     1  sample               140.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.90          
                     1  sample               149.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.95          
                     1  sample               155.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.99          
                     1  sample               174.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.999         
                     1  sample             16272.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.9999        
                     1  sample             29304.730             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p1.00          
                     1  sample           4165632.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark                                       
                     5  sample   933071      719.230 ±    4.662  ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.00          
                     5  sample               582.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.50          
                     5  sample               633.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.90          
                     5  sample               681.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.95          
                     5  sample               718.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.99          
                     5  sample               763.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.999         
                     5  sample             24544.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.9999        
                     5  sample             36588.339             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p1.00          
                     5  sample            178176.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark                                       
                    20  sample  1042420     4797.208 ±    8.407  ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.00          
                    20  sample              4052.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.50          
                    20  sample              4496.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.90          
                    20  sample              4712.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.95          
                    20  sample              4976.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.99          
                    20  sample             20864.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.999         
                    20  sample             32480.000             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p0.9999        
                    20  sample             64432.506             ns/op
   SensorBenchmark.recordWithAvgBenchmark:recordWithAvgBenchmark·p1.00          
                    20  sample            113280.000             ns/op
   sample            204288.000             ns/op
   ...
   SensorBenchmark.recordWithWindowedSumBenchmark                               
                    20  sample  1056588     4733.302 ±    8.413  ns/op
   
SensorBenchmark.recordWithWindowedSumBenchmark:recordWithWindowedSumBenchmark·p0.00
              20  sample              4052.000             ns/op
   
SensorBenchmark.recordWithWindowedSumBenchmark:recordWithWindowedSumBenchmark·p0.50
              20  sample              4416.000             ns/op
   
SensorBenchmark.recordWithWindowedSumBenchmark:recordWithWindowedSumBenchmark·p0.90
              20  sample              4656.000             ns/op
   
SensorBenchmark.recordWithWindowedSumBenchmark:recordWithWindowedSumBenchmark·p0.95
              20  sample              4976.000             ns/op
   
SensorBenchmark.recordWithWindowedSumBenchmark:recordWithWindowedSumBenchmark·p0.99
              20  sample             20672.000             ns/op
   
SensorBenchmark.recordWithWindowedSumBenchmark:recordWithWindowedSumBenchmark·p0.999
             20  sample             33088.000             ns/op
   
SensorBenchmark.recordWithWindowedSumBenchmark:recordWithWindowedSumBenchmark·p0.9999
            20  sample             64064.000             ns/op
   
SensorBenchmark.recordWithWindowedSumBenchmark:recordWithWindowedSumBenchmark·p1.00
              20  sample            160000.000             ns/op
   JMH benchmarks done
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to