Created
July 25, 2018 01:07
-
-
Save ttsugriy/c5c7719b9d7bb993d62f445a0be94e5c to your computer and use it in GitHub Desktop.
Dynamic proxy vs plain getter JMH benchmark.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# JMH version: 1.21 | |
# VM version: JDK 1.8.0_172, Java HotSpot(TM) 64-Bit Server VM, 25.172-b11 | |
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/bin/java | |
# VM options: <none> | |
# Warmup: 5 iterations, 10 s each | |
# Measurement: 5 iterations, 10 s each | |
# Timeout: 10 min per iteration | |
# Threads: 1 thread, will synchronize iterations | |
# Benchmark mode: Throughput, ops/time | |
# Benchmark: org.sample.MyBenchmark.testGetter | |
# Run progress: 0.00% complete, ETA 00:16:40 | |
# Fork: 1 of 5 | |
# Warmup Iteration 1: 315006321.024 ops/s | |
# Warmup Iteration 2: 300965823.311 ops/s | |
# Warmup Iteration 3: 350827221.085 ops/s | |
# Warmup Iteration 4: 368326131.592 ops/s | |
# Warmup Iteration 5: 358708872.183 ops/s | |
Iteration 1: 351597883.012 ops/s | |
Iteration 2: 353015506.577 ops/s | |
Iteration 3: 361518090.675 ops/s | |
Iteration 4: 351996034.209 ops/s | |
Iteration 5: 339052485.571 ops/s | |
# Run progress: 10.00% complete, ETA 00:15:04 | |
# Fork: 2 of 5 | |
# Warmup Iteration 1: 335564206.508 ops/s | |
# Warmup Iteration 2: 309203649.659 ops/s | |
# Warmup Iteration 3: 352698390.630 ops/s | |
# Warmup Iteration 4: 365605867.726 ops/s | |
# Warmup Iteration 5: 362646079.093 ops/s | |
Iteration 1: 300930642.972 ops/s | |
Iteration 2: 346621035.329 ops/s | |
Iteration 3: 362244121.241 ops/s | |
Iteration 4: 352039377.044 ops/s | |
Iteration 5: 353909242.541 ops/s | |
# Run progress: 20.00% complete, ETA 00:13:23 | |
# Fork: 3 of 5 | |
# Warmup Iteration 1: 325445656.841 ops/s | |
# Warmup Iteration 2: 304342218.134 ops/s | |
# Warmup Iteration 3: 350919433.473 ops/s | |
# Warmup Iteration 4: 351720154.580 ops/s | |
# Warmup Iteration 5: 352354854.044 ops/s | |
Iteration 1: 355556646.590 ops/s | |
Iteration 2: 362797682.030 ops/s | |
Iteration 3: 355447972.524 ops/s | |
Iteration 4: 349830527.250 ops/s | |
Iteration 5: 353495788.383 ops/s | |
# Run progress: 30.00% complete, ETA 00:11:43 | |
# Fork: 4 of 5 | |
# Warmup Iteration 1: 304896878.723 ops/s | |
# Warmup Iteration 2: 307392610.204 ops/s | |
# Warmup Iteration 3: 363668839.778 ops/s | |
# Warmup Iteration 4: 326630110.142 ops/s | |
# Warmup Iteration 5: 356298638.460 ops/s | |
Iteration 1: 363847659.878 ops/s | |
Iteration 2: 356601570.608 ops/s | |
Iteration 3: 349595273.378 ops/s | |
Iteration 4: 365426530.536 ops/s | |
Iteration 5: 348761435.637 ops/s | |
# Run progress: 40.00% complete, ETA 00:10:02 | |
# Fork: 5 of 5 | |
# Warmup Iteration 1: 306293940.788 ops/s | |
# Warmup Iteration 2: 322707088.950 ops/s | |
# Warmup Iteration 3: 358722563.604 ops/s | |
# Warmup Iteration 4: 380174542.322 ops/s | |
# Warmup Iteration 5: 349370701.183 ops/s | |
Iteration 1: 357469746.072 ops/s | |
Iteration 2: 356954944.512 ops/s | |
Iteration 3: 330982653.781 ops/s | |
Iteration 4: 353212788.268 ops/s | |
Iteration 5: 354160602.256 ops/s | |
Result "org.sample.MyBenchmark.testGetter": | |
351482649.635 ±(99.9%) 9678829.220 ops/s [Average] | |
(min, avg, max) = (300930642.972, 351482649.635, 365426530.536), stdev = 12920960.095 | |
CI (99.9%): [341803820.415, 361161478.855] (assumes normal distribution) | |
# JMH version: 1.21 | |
# VM version: JDK 1.8.0_172, Java HotSpot(TM) 64-Bit Server VM, 25.172-b11 | |
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/bin/java | |
# VM options: <none> | |
# Warmup: 5 iterations, 10 s each | |
# Measurement: 5 iterations, 10 s each | |
# Timeout: 10 min per iteration | |
# Threads: 1 thread, will synchronize iterations | |
# Benchmark mode: Throughput, ops/time | |
# Benchmark: org.sample.MyBenchmark.testProxy | |
# Run progress: 50.00% complete, ETA 00:08:22 | |
# Fork: 1 of 5 | |
# Warmup Iteration 1: 49878530.372 ops/s | |
# Warmup Iteration 2: 54802506.119 ops/s | |
# Warmup Iteration 3: 50007807.690 ops/s | |
# Warmup Iteration 4: 55831103.183 ops/s | |
# Warmup Iteration 5: 51240844.147 ops/s | |
Iteration 1: 52627278.842 ops/s | |
Iteration 2: 42976660.774 ops/s | |
Iteration 3: 51112350.921 ops/s | |
Iteration 4: 50641328.680 ops/s | |
Iteration 5: 51257746.907 ops/s | |
# Run progress: 60.00% complete, ETA 00:06:41 | |
# Fork: 2 of 5 | |
# Warmup Iteration 1: 46912769.376 ops/s | |
# Warmup Iteration 2: 48533679.510 ops/s | |
# Warmup Iteration 3: 49411774.464 ops/s | |
# Warmup Iteration 4: 49646420.097 ops/s | |
# Warmup Iteration 5: 49360590.094 ops/s | |
Iteration 1: 43256999.405 ops/s | |
Iteration 2: 49211546.709 ops/s | |
Iteration 3: 52633266.667 ops/s | |
Iteration 4: 52944020.334 ops/s | |
Iteration 5: 50437621.129 ops/s | |
# Run progress: 70.00% complete, ETA 00:05:01 | |
# Fork: 3 of 5 | |
# Warmup Iteration 1: 47918923.703 ops/s | |
# Warmup Iteration 2: 48745688.600 ops/s | |
# Warmup Iteration 3: 52504865.607 ops/s | |
# Warmup Iteration 4: 51730935.869 ops/s | |
# Warmup Iteration 5: 49398619.580 ops/s | |
Iteration 1: 49600004.681 ops/s | |
Iteration 2: 51512715.762 ops/s | |
Iteration 3: 51695709.388 ops/s | |
Iteration 4: 49741460.830 ops/s | |
Iteration 5: 49849417.116 ops/s | |
# Run progress: 80.00% complete, ETA 00:03:20 | |
# Fork: 4 of 5 | |
# Warmup Iteration 1: 52812209.079 ops/s | |
# Warmup Iteration 2: 49269312.077 ops/s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.sample; | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.Scope; | |
import org.openjdk.jmh.annotations.State; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
@State(Scope.Benchmark) | |
public class MyBenchmark { | |
@Retention(RetentionPolicy.RUNTIME) | |
public @interface Param { | |
String name(); | |
} | |
@Param(name = "Benchmark") | |
static class Pojo { | |
private final String name; | |
Pojo(String name) { | |
this.name = name; | |
} | |
public String getName() { | |
return name; | |
} | |
} | |
private Pojo pojo = new Pojo("Benchmark"); | |
private Param param = pojo.getClass().getAnnotation(Param.class); | |
@Benchmark | |
public String testGetter() { | |
return pojo.getName(); | |
} | |
@Benchmark | |
public String testProxy() { | |
return param.name(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment