Skip to content

Instantly share code, notes, and snippets.

@dcapwell
Last active August 29, 2015 14:09
Show Gist options
  • Save dcapwell/14de46f76d7118eda253 to your computer and use it in GitHub Desktop.
Save dcapwell/14de46f76d7118eda253 to your computer and use it in GitHub Desktop.
Java recursion with sync blocks
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'me.champeau.gradle:jmh-gradle-plugin:0.1.3'
}
}
repositories {
jcenter() // repository from which JMH will be downloaded
}
apply plugin: 'me.champeau.gradle.jmh'
apply plugin: 'java'
task wrapper(type: Wrapper) {
gradleVersion = '2.1'
}
package com.github.dcapwell.jmh.java;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OperationsPerInvocation;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import java.util.concurrent.TimeUnit;
@State(Scope.Benchmark)
@BenchmarkMode(Mode.All)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Threads(-1)
public class RecursiveLocks {
private final Object recursiveLock = new Object();
private final Object topLock = new Object();
private final int depth = 20;
@Benchmark
@OperationsPerInvocation(20)
public void recursiveLocks() {
synchronized (recursiveLock) {
recursiveLocks(depth);
}
}
private int recursiveLocks(int depth) {
synchronized (recursiveLock) {
if (depth >= 0) {
return recursiveLocks(depth - 1);
} else {
return depth + 1;
}
}
}
@Benchmark
@OperationsPerInvocation(20)
public void recursiveTopOnlyLock() {
synchronized (topLock) {
recursiveTopOnlyLock(depth);
}
}
private int recursiveTopOnlyLock(int depth) {
if (depth >= 0) {
return recursiveTopOnlyLock(depth - 1);
} else {
return depth + 1;
}
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(RecursiveLocks.class.getSimpleName())
.warmupIterations(1)
.measurementIterations(1)
.forks(2)
.build();
new Runner(opt).run();
}
}
/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/bin/java -Dfile.encoding=UTF-8 -classpath /Users/dcapwell/src/random/java-perf/build/classes/test:/Users/dcapwell/.gradle/caches/modules-2/files-2.1/org.openjdk.jmh/jmh-core/1.1.1/9de80f9d2f387b1a10e05e623cf7119549ec57a/jmh-core-1.1.1.jar:/Users/dcapwell/.gradle/caches/modules-2/files-2.1/org.openjdk.jmh/jmh-generator-annprocess/1.1.1/3a9ace79232e9d037600776f9bfd9a4211d31508/jmh-generator-annprocess-1.1.1.jar:/Users/dcapwell/.gradle/caches/modules-2/files-2.1/net.sf.jopt-simple/jopt-simple/4.6/306816fb57cf94f108a43c95731b08934dcae15c/jopt-simple-4.6.jar:/Users/dcapwell/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-math3/3.2/ec2544ab27e110d2d431bdad7d538ed509b21e62/commons-math3-3.2.jar org.openjdk.jmh.Main com.github.dcapwell.jmh.java.RecursiveLocks.recursiveLocks
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
# Detecting actual CPU count: 8 detected
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/jre/bin/java
# VM options: -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true
# Warmup: 20 iterations, 1 s each
# Measurement: 20 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 8 threads, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: com.github.dcapwell.jmh.java.RecursiveLocks.recursiveLocks
# Run progress: 0.00% complete, ETA 00:02:00
# Fork: 1 of 1
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
# Warmup Iteration 1: 0.007 ops/ns
# Warmup Iteration 2: 0.007 ops/ns
# Warmup Iteration 3: 0.007 ops/ns
# Warmup Iteration 4: 0.007 ops/ns
# Warmup Iteration 5: 0.007 ops/ns
# Warmup Iteration 6: 0.006 ops/ns
# Warmup Iteration 7: 0.007 ops/ns
# Warmup Iteration 8: 0.007 ops/ns
# Warmup Iteration 9: 0.007 ops/ns
# Warmup Iteration 10: 0.007 ops/ns
# Warmup Iteration 11: 0.007 ops/ns
# Warmup Iteration 12: 0.007 ops/ns
# Warmup Iteration 13: 0.007 ops/ns
# Warmup Iteration 14: 0.007 ops/ns
# Warmup Iteration 15: 0.007 ops/ns
# Warmup Iteration 16: 0.007 ops/ns
# Warmup Iteration 17: 0.007 ops/ns
# Warmup Iteration 18: 0.007 ops/ns
# Warmup Iteration 19: 0.007 ops/ns
# Warmup Iteration 20: 0.007 ops/ns
Iteration 1: 0.007 ops/ns
Iteration 2: 0.007 ops/ns
Iteration 3: 0.007 ops/ns
Iteration 4: 0.007 ops/ns
Iteration 5: 0.007 ops/ns
Iteration 6: 0.007 ops/ns
Iteration 7: 0.007 ops/ns
Iteration 8: 0.007 ops/ns
Iteration 9: 0.007 ops/ns
Iteration 10: 0.007 ops/ns
Iteration 11: 0.007 ops/ns
Iteration 12: 0.007 ops/ns
Iteration 13: 0.007 ops/ns
Iteration 14: 0.007 ops/ns
Iteration 15: 0.007 ops/ns
Iteration 16: 0.007 ops/ns
Iteration 17: 0.007 ops/ns
Iteration 18: 0.007 ops/ns
Iteration 19: 0.006 ops/ns
Iteration 20: 0.007 ops/ns
Result: 0.007 ±(99.9%) 0.000 ops/ns [Average]
Statistics: (min, avg, max) = (0.006, 0.007, 0.007), stdev = 0.000
Confidence interval (99.9%): [0.007, 0.007]
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/jre/bin/java
# VM options: -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true
# Warmup: 20 iterations, 1 s each
# Measurement: 20 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 8 threads, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: com.github.dcapwell.jmh.java.RecursiveLocks.recursiveLocks
# Run progress: 33.33% complete, ETA 00:01:44
# Fork: 1 of 1
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
# Warmup Iteration 1: 12516.249 ±(99.9%) 34723.334 ns/op
# Warmup Iteration 2: 1116.934 ±(99.9%) 570.245 ns/op
# Warmup Iteration 3: 1133.496 ±(99.9%) 462.910 ns/op
# Warmup Iteration 4: 1576.626 ±(99.9%) 2389.354 ns/op
# Warmup Iteration 5: 1517.481 ±(99.9%) 2235.016 ns/op
# Warmup Iteration 6: 1308.949 ±(99.9%) 464.364 ns/op
# Warmup Iteration 7: 1278.275 ±(99.9%) 1130.364 ns/op
# Warmup Iteration 8: 1153.334 ±(99.9%) 751.301 ns/op
# Warmup Iteration 9: 1909.338 ±(99.9%) 3740.311 ns/op
# Warmup Iteration 10: 1168.874 ±(99.9%) 604.633 ns/op
# Warmup Iteration 11: 1311.854 ±(99.9%) 1377.824 ns/op
# Warmup Iteration 12: 1305.404 ±(99.9%) 873.291 ns/op
# Warmup Iteration 13: 1508.848 ±(99.9%) 2237.241 ns/op
# Warmup Iteration 14: 1316.479 ±(99.9%) 1010.011 ns/op
# Warmup Iteration 15: 1237.634 ±(99.9%) 1063.252 ns/op
# Warmup Iteration 16: 1326.815 ±(99.9%) 796.763 ns/op
# Warmup Iteration 17: 1584.561 ±(99.9%) 1718.116 ns/op
# Warmup Iteration 18: 1418.097 ±(99.9%) 1168.083 ns/op
# Warmup Iteration 19: 1270.748 ±(99.9%) 1078.397 ns/op
# Warmup Iteration 20: 1292.962 ±(99.9%) 827.844 ns/op
Iteration 1: 1258.917 ±(99.9%) 967.711 ns/op
Iteration 2: 1433.937 ±(99.9%) 1538.037 ns/op
Iteration 3: 1177.320 ±(99.9%) 388.744 ns/op
Iteration 4: 1183.096 ±(99.9%) 714.330 ns/op
Iteration 5: 1245.722 ±(99.9%) 787.845 ns/op
Iteration 6: 1312.872 ±(99.9%) 758.740 ns/op
Iteration 7: 1242.967 ±(99.9%) 578.822 ns/op
Iteration 8: 1672.855 ±(99.9%) 2619.951 ns/op
Iteration 9: 1311.502 ±(99.9%) 1428.621 ns/op
Iteration 10: 1404.844 ±(99.9%) 1437.893 ns/op
Iteration 11: 1430.539 ±(99.9%) 1694.973 ns/op
Iteration 12: 1215.311 ±(99.9%) 954.093 ns/op
Iteration 13: 1536.439 ±(99.9%) 2281.212 ns/op
Iteration 14: 1262.753 ±(99.9%) 870.076 ns/op
Iteration 15: 1258.085 ±(99.9%) 763.620 ns/op
Iteration 16: 1389.328 ±(99.9%) 1316.386 ns/op
Iteration 17: 1349.236 ±(99.9%) 716.876 ns/op
Iteration 18: 1251.426 ±(99.9%) 520.836 ns/op
Iteration 19: 1657.021 ±(99.9%) 2001.768 ns/op
Iteration 20: 1342.235 ±(99.9%) 1128.476 ns/op
Result: 1346.820 ±(99.9%) 123.815 ns/op [Average]
Statistics: (min, avg, max) = (1177.320, 1346.820, 1672.855), stdev = 142.586
Confidence interval (99.9%): [1223.005, 1470.635]
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/jre/bin/java
# VM options: -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true
# Warmup: 20 iterations, 1 s each
# Measurement: 20 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 8 threads, will synchronize iterations
# Benchmark mode: Sampling time
# Benchmark: com.github.dcapwell.jmh.java.RecursiveLocks.recursiveLocks
# Run progress: 66.67% complete, ETA 00:00:53
# Fork: 1 of 1
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
# Warmup Iteration 1: n = 142571, mean = 2349 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 50, 350, 400, 1250, 21632, 31803, 5742592, 17530880 ns/op
# Warmup Iteration 2: n = 117927, mean = 2448 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 350, 400, 550, 11936, 33477, 2777704, 34209792 ns/op
# Warmup Iteration 3: n = 92909, mean = 2126 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 200, 6048, 16832, 24736, 37836, 264738, 3162112 ns/op
# Warmup Iteration 4: n = 72043, mean = 2719 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 350, 10096, 20288, 28420, 40061, 147852, 4026368 ns/op
# Warmup Iteration 5: n = 57999, mean = 3269 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 15088, 19392, 26592, 41792, 56614, 61312 ns/op
# Warmup Iteration 6: n = 57367, mean = 3340 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 13840, 18080, 25492, 45322, 61686, 70912 ns/op
# Warmup Iteration 7: n = 79885, mean = 1600 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 350, 500, 10240, 21024, 35727, 53389, 15138816 ns/op
# Warmup Iteration 8: n = 61884, mean = 2275 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 10240, 14992, 22176, 37007, 55111, 64384 ns/op
# Warmup Iteration 9: n = 61979, mean = 2442 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 10848, 18176, 25344, 33600, 44329, 56448 ns/op
# Warmup Iteration 10: n = 62343, mean = 2409 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 10848, 17888, 25120, 35178, 51170, 94848 ns/op
# Warmup Iteration 11: n = 62414, mean = 2451 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 10496, 18784, 25632, 34262, 43697, 52672 ns/op
# Warmup Iteration 12: n = 63021, mean = 2451 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 10400, 18048, 26482, 39295, 119951, 1212416 ns/op
# Warmup Iteration 13: n = 62182, mean = 2469 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 50, 150, 10848, 18624, 25440, 34228, 50893, 1951744 ns/op
# Warmup Iteration 14: n = 77871, mean = 1943 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 300, 4848, 13888, 23936, 37632, 300252, 5251072 ns/op
# Warmup Iteration 15: n = 67451, mean = 2290 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 8992, 16384, 25184, 45586, 254071, 1142784 ns/op
# Warmup Iteration 16: n = 71676, mean = 2127 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 300, 6544, 15696, 26144, 43475, 459414, 528384 ns/op
# Warmup Iteration 17: n = 68180, mean = 2292 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 8336, 16640, 25184, 39360, 312134, 2564096 ns/op
# Warmup Iteration 18: n = 64597, mean = 2337 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 9440, 17632, 24480, 34586, 94186, 957440 ns/op
# Warmup Iteration 19: n = 65329, mean = 2298 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 8944, 17472, 24800, 39852, 145842, 1691648 ns/op
# Warmup Iteration 20: n = 69851, mean = 1653 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 850, 11200, 20800, 30793, 52136, 14761984 ns/op
Iteration 1: n = 66757, mean = 1845 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 6496, 15440, 22592, 31367, 51075, 583680 ns/op
Iteration 2: n = 67132, mean = 1776 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 4800, 15440, 22976, 30931, 61190, 1027072 ns/op
Iteration 3: n = 67918, mean = 1738 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 4496, 15248, 22714, 34768, 74466, 260352 ns/op
Iteration 4: n = 66897, mean = 1927 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 6944, 14288, 21985, 33562, 51544, 7413760 ns/op
Iteration 5: n = 68907, mean = 1841 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 6106, 13773, 22048, 33024, 73140, 3997696 ns/op
Iteration 6: n = 67517, mean = 1830 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 5955, 14400, 22624, 34622, 55953, 2940928 ns/op
Iteration 7: n = 66833, mean = 1879 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 50, 150, 6896, 15136, 23232, 31312, 47276, 156672 ns/op
Iteration 8: n = 67138, mean = 1850 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 6544, 15136, 23271, 32508, 55381, 93824 ns/op
Iteration 9: n = 66861, mean = 1836 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 4944, 15792, 23404, 33618, 48014, 742400 ns/op
Iteration 10: n = 67569, mean = 1811 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 6200, 14800, 23488, 35612, 67321, 91648 ns/op
Iteration 11: n = 70058, mean = 1635 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 4800, 13696, 21920, 30974, 46397, 330240 ns/op
Iteration 12: n = 68754, mean = 1697 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 6944, 13200, 21632, 29472, 43424, 294912 ns/op
Iteration 13: n = 70420, mean = 1612 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 100, 4144, 13648, 21984, 29194, 45984, 860160 ns/op
Iteration 14: n = 69412, mean = 1686 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 50, 100, 5648, 13488, 21696, 31934, 45869, 1753088 ns/op
Iteration 15: n = 67844, mean = 1764 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 50, 150, 6248, 14144, 22848, 32579, 64349, 112384 ns/op
Iteration 16: n = 67285, mean = 1804 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 6296, 14800, 22793, 33774, 46061, 58880 ns/op
Iteration 17: n = 64983, mean = 1890 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 7896, 14448, 23232, 33984, 48705, 97536 ns/op
Iteration 18: n = 68404, mean = 1766 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 4944, 14048, 22976, 40038, 144466, 195584 ns/op
Iteration 19: n = 67541, mean = 1869 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 5544, 15888, 22976, 33600, 52276, 1560576 ns/op
Iteration 20: n = 66605, mean = 1858 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 150, 7144, 14944, 23392, 34956, 42606, 59968 ns/op
Result: 1794.347 ±(99.9%) 29.171 ns/op [Average]
Statistics: (min, avg, max) = (0.000, 1794.347, 7413760.000), stdev = 10318.838
Confidence interval (99.9%): [1765.175, 1823.518]
Samples, N = 1354835
mean = 1794.347 ±(99.9%) 29.171 ns/op
min = 0.000 ns/op
p( 0.0000) = 0.000 ns/op
p(50.0000) = 150.000 ns/op
p(90.0000) = 6096.000 ns/op
p(95.0000) = 14544.000 ns/op
p(99.0000) = 22720.000 ns/op
p(99.9000) = 32896.000 ns/op
p(99.9900) = 58287.744 ns/op
p(99.9990) = 795585.126 ns/op
p(99.9999) = 6201617.515 ns/op
max = 7413760.000 ns/op
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/jre/bin/java
# VM options: -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true
# Warmup: <none>
# Measurement: 1 iterations, single-shot each
# Timeout: 10 min per iteration
# Threads: 8 threads
# Benchmark mode: Single shot invocation time
# Benchmark: com.github.dcapwell.jmh.java.RecursiveLocks.recursiveLocks
# Run progress: 100.00% complete, ETA 00:00:00
# Fork: 1 of 1
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
Iteration 1: 33750.000 ±(99.9%) 59624.817 ns
Run result: 33750.00 ns (<= 2 samples)
# Run complete. Total time: 00:02:37
Benchmark Mode Samples Score Error Units
c.g.d.j.j.RecursiveLocks.recursiveLocks thrpt 20 0.007 ± 0.000 ops/ns
c.g.d.j.j.RecursiveLocks.recursiveLocks avgt 20 1346.820 ± 123.815 ns/op
c.g.d.j.j.RecursiveLocks.recursiveLocks sample 1354835 1794.347 ± 29.171 ns/op
c.g.d.j.j.RecursiveLocks.recursiveLocks ss 1 33750.000 ± NaN ns
Process finished with exit code 0
/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/bin/java -Dfile.encoding=UTF-8 -classpath /Users/dcapwell/src/random/java-perf/build/classes/test:/Users/dcapwell/.gradle/caches/modules-2/files-2.1/org.openjdk.jmh/jmh-core/1.1.1/9de80f9d2f387b1a10e05e623cf7119549ec57a/jmh-core-1.1.1.jar:/Users/dcapwell/.gradle/caches/modules-2/files-2.1/org.openjdk.jmh/jmh-generator-annprocess/1.1.1/3a9ace79232e9d037600776f9bfd9a4211d31508/jmh-generator-annprocess-1.1.1.jar:/Users/dcapwell/.gradle/caches/modules-2/files-2.1/net.sf.jopt-simple/jopt-simple/4.6/306816fb57cf94f108a43c95731b08934dcae15c/jopt-simple-4.6.jar:/Users/dcapwell/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-math3/3.2/ec2544ab27e110d2d431bdad7d538ed509b21e62/commons-math3-3.2.jar org.openjdk.jmh.Main com.github.dcapwell.jmh.java.RecursiveLocks.recursiveTopOnlyLock
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
# Detecting actual CPU count: 8 detected
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/jre/bin/java
# VM options: -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true
# Warmup: 20 iterations, 1 s each
# Measurement: 20 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 8 threads, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: com.github.dcapwell.jmh.java.RecursiveLocks.recursiveTopOnlyLock
# Run progress: 0.00% complete, ETA 00:02:00
# Fork: 1 of 1
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
# Warmup Iteration 1: 0.293 ops/ns
# Warmup Iteration 2: 0.293 ops/ns
# Warmup Iteration 3: 0.285 ops/ns
# Warmup Iteration 4: 0.283 ops/ns
# Warmup Iteration 5: 0.287 ops/ns
# Warmup Iteration 6: 0.287 ops/ns
# Warmup Iteration 7: 0.286 ops/ns
# Warmup Iteration 8: 0.285 ops/ns
# Warmup Iteration 9: 0.295 ops/ns
# Warmup Iteration 10: 0.304 ops/ns
# Warmup Iteration 11: 0.304 ops/ns
# Warmup Iteration 12: 0.302 ops/ns
# Warmup Iteration 13: 0.303 ops/ns
# Warmup Iteration 14: 0.302 ops/ns
# Warmup Iteration 15: 0.303 ops/ns
# Warmup Iteration 16: 0.304 ops/ns
# Warmup Iteration 17: 0.300 ops/ns
# Warmup Iteration 18: 0.303 ops/ns
# Warmup Iteration 19: 0.304 ops/ns
# Warmup Iteration 20: 0.305 ops/ns
Iteration 1: 0.303 ops/ns
Iteration 2: 0.303 ops/ns
Iteration 3: 0.305 ops/ns
Iteration 4: 0.289 ops/ns
Iteration 5: 0.303 ops/ns
Iteration 6: 0.304 ops/ns
Iteration 7: 0.303 ops/ns
Iteration 8: 0.292 ops/ns
Iteration 9: 0.304 ops/ns
Iteration 10: 0.305 ops/ns
Iteration 11: 0.305 ops/ns
Iteration 12: 0.304 ops/ns
Iteration 13: 0.304 ops/ns
Iteration 14: 0.291 ops/ns
Iteration 15: 0.303 ops/ns
Iteration 16: 0.303 ops/ns
Iteration 17: 0.304 ops/ns
Iteration 18: 0.293 ops/ns
Iteration 19: 0.304 ops/ns
Iteration 20: 0.304 ops/ns
Result: 0.301 ±(99.9%) 0.004 ops/ns [Average]
Statistics: (min, avg, max) = (0.289, 0.301, 0.305), stdev = 0.005
Confidence interval (99.9%): [0.297, 0.306]
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/jre/bin/java
# VM options: -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true
# Warmup: 20 iterations, 1 s each
# Measurement: 20 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 8 threads, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: com.github.dcapwell.jmh.java.RecursiveLocks.recursiveTopOnlyLock
# Run progress: 33.33% complete, ETA 00:01:36
# Fork: 1 of 1
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
# Warmup Iteration 1: 25.774 ±(99.9%) 0.879 ns/op
# Warmup Iteration 2: 25.627 ±(99.9%) 0.699 ns/op
# Warmup Iteration 3: 26.639 ±(99.9%) 0.923 ns/op
# Warmup Iteration 4: 26.621 ±(99.9%) 0.959 ns/op
# Warmup Iteration 5: 26.569 ±(99.9%) 0.685 ns/op
# Warmup Iteration 6: 26.632 ±(99.9%) 1.101 ns/op
# Warmup Iteration 7: 26.577 ±(99.9%) 0.639 ns/op
# Warmup Iteration 8: 26.601 ±(99.9%) 1.068 ns/op
# Warmup Iteration 9: 26.716 ±(99.9%) 1.232 ns/op
# Warmup Iteration 10: 27.137 ±(99.9%) 0.871 ns/op
# Warmup Iteration 11: 27.227 ±(99.9%) 0.915 ns/op
# Warmup Iteration 12: 27.164 ±(99.9%) 1.080 ns/op
# Warmup Iteration 13: 27.131 ±(99.9%) 0.682 ns/op
# Warmup Iteration 14: 27.338 ±(99.9%) 0.765 ns/op
# Warmup Iteration 15: 27.246 ±(99.9%) 0.709 ns/op
# Warmup Iteration 16: 27.180 ±(99.9%) 0.800 ns/op
# Warmup Iteration 17: 27.844 ±(99.9%) 0.568 ns/op
# Warmup Iteration 18: 28.416 ±(99.9%) 0.569 ns/op
# Warmup Iteration 19: 27.202 ±(99.9%) 0.778 ns/op
# Warmup Iteration 20: 26.928 ±(99.9%) 1.082 ns/op
Iteration 1: 27.340 ±(99.9%) 1.013 ns/op
Iteration 2: 27.176 ±(99.9%) 1.216 ns/op
Iteration 3: 27.139 ±(99.9%) 1.069 ns/op
Iteration 4: 27.134 ±(99.9%) 1.123 ns/op
Iteration 5: 27.088 ±(99.9%) 0.754 ns/op
Iteration 6: 27.227 ±(99.9%) 0.583 ns/op
Iteration 7: 27.236 ±(99.9%) 0.864 ns/op
Iteration 8: 27.300 ±(99.9%) 0.655 ns/op
Iteration 9: 27.339 ±(99.9%) 0.905 ns/op
Iteration 10: 27.214 ±(99.9%) 0.675 ns/op
Iteration 11: 27.200 ±(99.9%) 0.461 ns/op
Iteration 12: 27.091 ±(99.9%) 0.809 ns/op
Iteration 13: 27.110 ±(99.9%) 0.993 ns/op
Iteration 14: 27.240 ±(99.9%) 1.355 ns/op
Iteration 15: 27.212 ±(99.9%) 1.021 ns/op
Iteration 16: 27.395 ±(99.9%) 0.618 ns/op
Iteration 17: 27.187 ±(99.9%) 0.924 ns/op
Iteration 18: 27.158 ±(99.9%) 1.230 ns/op
Iteration 19: 27.208 ±(99.9%) 0.662 ns/op
Iteration 20: 27.168 ±(99.9%) 0.695 ns/op
Result: 27.208 ±(99.9%) 0.073 ns/op [Average]
Statistics: (min, avg, max) = (27.088, 27.208, 27.395), stdev = 0.084
Confidence interval (99.9%): [27.135, 27.281]
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/jre/bin/java
# VM options: -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true
# Warmup: 20 iterations, 1 s each
# Measurement: 20 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 8 threads, will synchronize iterations
# Benchmark mode: Sampling time
# Benchmark: com.github.dcapwell.jmh.java.RecursiveLocks.recursiveTopOnlyLock
# Run progress: 66.67% complete, ETA 00:00:48
# Fork: 1 of 1
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
# Warmup Iteration 1: n = 186481, mean = 153 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 4448, 13113, 81609, 625664 ns/op
# Warmup Iteration 2: n = 90513, mean = 128 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 4296, 10944, 22484, 44352 ns/op
# Warmup Iteration 3: n = 91133, mean = 208 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 8048, 15536, 23345, 28672 ns/op
# Warmup Iteration 4: n = 93132, mean = 216 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 8048, 14890, 20846, 24000 ns/op
# Warmup Iteration 5: n = 94045, mean = 198 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 7344, 14190, 19135, 27200 ns/op
# Warmup Iteration 6: n = 94055, mean = 194 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 7421, 14333, 20480, 24480 ns/op
# Warmup Iteration 7: n = 94159, mean = 201 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 7544, 14088, 20869, 26592 ns/op
# Warmup Iteration 8: n = 93325, mean = 201 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 7800, 14288, 19040, 24384 ns/op
# Warmup Iteration 9: n = 118531, mean = 150 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6096, 12192, 17290, 24576 ns/op
# Warmup Iteration 10: n = 118691, mean = 157 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6448, 12448, 16605, 155392 ns/op
# Warmup Iteration 11: n = 118503, mean = 158 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6400, 12240, 16928, 23648 ns/op
# Warmup Iteration 12: n = 119423, mean = 152 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6248, 11820, 15606, 25344 ns/op
# Warmup Iteration 13: n = 117176, mean = 155 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6296, 12048, 16571, 91008 ns/op
# Warmup Iteration 14: n = 119562, mean = 153 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6248, 11717, 16264, 37440 ns/op
# Warmup Iteration 15: n = 119782, mean = 157 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6400, 12048, 16901, 20640 ns/op
# Warmup Iteration 16: n = 118743, mean = 157 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6496, 12096, 15762, 19776 ns/op
# Warmup Iteration 17: n = 118618, mean = 159 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6496, 12096, 16841, 20480 ns/op
# Warmup Iteration 18: n = 99938, mean = 182 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 7200, 13491, 18689, 25344 ns/op
# Warmup Iteration 19: n = 100195, mean = 187 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 7200, 14183, 18687, 23296 ns/op
# Warmup Iteration 20: n = 99755, mean = 185 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 7248, 14812, 19651, 25120 ns/op
Iteration 1: n = 99461, mean = 188 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 7248, 13888, 20017, 26944 ns/op
Iteration 2: n = 122714, mean = 147 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6137, 12754, 19072, 30848 ns/op
Iteration 3: n = 121540, mean = 148 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6048, 12918, 18868, 34112 ns/op
Iteration 4: n = 122161, mean = 152 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6344, 12800, 19065, 30720 ns/op
Iteration 5: n = 122316, mean = 148 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6144, 12721, 20628, 65344 ns/op
Iteration 6: n = 121885, mean = 157 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6600, 12736, 17400, 23040 ns/op
Iteration 7: n = 121049, mean = 164 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6648, 12736, 19842, 68608 ns/op
Iteration 8: n = 122667, mean = 148 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6096, 12144, 16879, 20832 ns/op
Iteration 9: n = 121927, mean = 153 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6296, 12496, 17453, 23648 ns/op
Iteration 10: n = 121993, mean = 151 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6200, 12337, 18099, 33344 ns/op
Iteration 11: n = 116401, mean = 161 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 6000, 10944, 14886, 21888 ns/op
Iteration 12: n = 116163, mean = 161 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 5848, 10088, 12981, 29088 ns/op
Iteration 13: n = 116093, mean = 157 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 5848, 10240, 13950, 17472 ns/op
Iteration 14: n = 115989, mean = 154 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 5696, 10496, 14544, 17280 ns/op
Iteration 15: n = 120876, mean = 158 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 50, 6848, 17376, 24986, 32288 ns/op
Iteration 16: n = 120289, mean = 156 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 50, 6848, 16996, 25274, 31424 ns/op
Iteration 17: n = 120157, mean = 157 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 50, 6848, 17440, 24826, 32960 ns/op
Iteration 18: n = 119720, mean = 157 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 50, 6848, 17097, 25540, 31296 ns/op
Iteration 19: n = 98895, mean = 181 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 7200, 13543, 18887, 21888 ns/op
Iteration 20: n = 99194, mean = 180 ns/op, p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = 0, 0, 50, 100, 7048, 13239, 18656, 27872 ns/op
Result: 158.377 ±(99.9%) 2.387 ns/op [Average]
Statistics: (min, avg, max) = (0.000, 158.377, 68608.000), stdev = 1109.865
Confidence interval (99.9%): [155.990, 160.763]
Samples, N = 2341490
mean = 158.377 ±(99.9%) 2.387 ns/op
min = 0.000 ns/op
p( 0.0000) = 0.000 ns/op
p(50.0000) = 0.000 ns/op
p(90.0000) = 50.000 ns/op
p(95.0000) = 100.000 ns/op
p(99.0000) = 6344.000 ns/op
p(99.9000) = 13600.000 ns/op
p(99.9900) = 20480.000 ns/op
p(99.9990) = 29973.783 ns/op
p(99.9999) = 61235.180 ns/op
max = 68608.000 ns/op
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/jre/bin/java
# VM options: -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true
# Warmup: <none>
# Measurement: 1 iterations, single-shot each
# Timeout: 10 min per iteration
# Threads: 8 threads
# Benchmark mode: Single shot invocation time
# Benchmark: com.github.dcapwell.jmh.java.RecursiveLocks.recursiveTopOnlyLock
# Run progress: 100.00% complete, ETA 00:00:00
# Fork: 1 of 1
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
Iteration 1: 29500.000 ±(99.9%) 55761.911 ns
Run result: 29500.00 ns (<= 2 samples)
# Run complete. Total time: 00:02:26
Benchmark Mode Samples Score Error Units
c.g.d.j.j.RecursiveLocks.recursiveTopOnlyLock thrpt 20 0.301 ± 0.004 ops/ns
c.g.d.j.j.RecursiveLocks.recursiveTopOnlyLock avgt 20 27.208 ± 0.073 ns/op
c.g.d.j.j.RecursiveLocks.recursiveTopOnlyLock sample 2341490 158.377 ± 2.387 ns/op
c.g.d.j.j.RecursiveLocks.recursiveTopOnlyLock ss 1 29500.000 ± NaN ns
Process finished with exit code 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment