Skip to content

Instantly share code, notes, and snippets.

@patrickfav
Last active April 27, 2019 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickfav/8359c2fb2f7040edefdc0df9badc4093 to your computer and use it in GitHub Desktop.
Save patrickfav/8359c2fb2f7040edefdc0df9badc4093 to your computer and use it in GitHub Desktop.
Simple JMH Benchmark to test Hex vs Base64 Encoding Performance
import at.favre.lib.bytes.Bytes;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import java.util.concurrent.TimeUnit;
@SuppressWarnings("CheckStyle")
@State(Scope.Thread)
@Fork(1)
@Warmup(iterations = 2, time = 4)
@Measurement(iterations = 3, time = 6)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public class EncodingBenchmark {
@State(Scope.Thread)
public static class BenchmarkState {
private Bytes bytes8Byte;
private Bytes bytes16Byte;
private Bytes bytes1024Byte;
private String hexEncoded8Byte;
private String hexEncoded16Byte;
private String hexEncoded1024Byte;
private String base32Encoded8Byte;
private String base32Encoded16Byte;
private String base32Encoded1024Byte;
private String base64Encoded8Byte;
private String base64Encoded16Byte;
private String base64Encoded1024Byte;
@Setup
public void setup() {
bytes8Byte = Bytes.random(8);
bytes16Byte = Bytes.random(16);
bytes1024Byte = Bytes.random(1024);
hexEncoded8Byte = bytes8Byte.encodeHex();
hexEncoded16Byte = bytes16Byte.encodeHex();
hexEncoded1024Byte = bytes1024Byte.encodeHex();
base32Encoded8Byte = bytes8Byte.encodeBase32();
base32Encoded16Byte = bytes16Byte.encodeBase32();
base32Encoded1024Byte = bytes1024Byte.encodeBase32();
base64Encoded8Byte = bytes8Byte.encodeBase64();
base64Encoded16Byte = bytes16Byte.encodeBase64();
base64Encoded1024Byte = bytes1024Byte.encodeBase64();
}
}
@Benchmark
public void hexEncoding8Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(state.bytes8Byte.encodeHex());
}
@Benchmark
public void hexDecoding8Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(Bytes.parseHex(state.hexEncoded8Byte));
}
@Benchmark
public void hexEncoding16Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(state.bytes16Byte.encodeHex());
}
@Benchmark
public void hexDecoding16Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(Bytes.parseHex(state.hexEncoded16Byte));
}
@Benchmark
public void hexEncoding1024Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(state.bytes1024Byte.encodeHex());
}
@Benchmark
public void hexDecoding1024Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(Bytes.parseHex(state.hexEncoded1024Byte));
}
@Benchmark
public void base64Encoding8Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(state.bytes8Byte.encodeBase64());
}
@Benchmark
public void base64Decoding8Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(Bytes.parseBase64(state.base64Encoded8Byte));
}
@Benchmark
public void base64Encoding16Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(state.bytes16Byte.encodeBase64());
}
@Benchmark
public void base64Decoding16Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(Bytes.parseBase64(state.base64Encoded16Byte));
}
@Benchmark
public void base64Encoding1024Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(state.bytes1024Byte.encodeBase64());
}
@Benchmark
public void base64Decoding1024Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(Bytes.parseBase64(state.base64Encoded1024Byte));
}
@Benchmark
public void base32Encoding8Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(state.bytes8Byte.encodeBase32());
}
@Benchmark
public void base32Decoding8Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(Bytes.parseBase32(state.base32Encoded8Byte));
}
@Benchmark
public void base32Encoding16Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(state.bytes16Byte.encodeBase32());
}
@Benchmark
public void base32Decoding16Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(Bytes.parseBase32(state.base32Encoded16Byte));
}
@Benchmark
public void base32Encoding1024Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(state.bytes1024Byte.encodeBase32());
}
@Benchmark
public void base32Decoding1024Byte(BenchmarkState state, Blackhole blackhole) {
blackhole.consume(Bytes.parseBase32(state.base32Encoded1024Byte));
}
}
"C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\bin\java.exe" -Dfile.encoding=UTF-8 -classpath C:\Users\PatrickF\workspaces\id-mask\modules\benchmark-jmh\target\classes;C:\Users\PatrickF\.m2\repository\org\openjdk\jmh\jmh-core\1.21\jmh-core-1.21.jar;C:\Users\PatrickF\.m2\repository\net\sf\jopt-simple\jopt-simple\4.6\jopt-simple-4.6.jar;C:\Users\PatrickF\.m2\repository\org\apache\commons\commons-math3\3.2\commons-math3-3.2.jar;C:\Users\PatrickF\.m2\repository\at\favre\lib\bytes\1.1.0\bytes-1.1.0.jar;C:\Users\PatrickF\workspaces\id-mask\modules\id-mask\target\classes;C:\Users\PatrickF\.m2\repository\at\favre\lib\hkdf\1.0.1\hkdf-1.0.1.jar;C:\Users\PatrickF\.m2\repository\com\google\auto\value\auto-value-annotations\1.6.3\auto-value-annotations-1.6.3.jar;C:\Users\PatrickF\.m2\repository\org\jetbrains\annotations\15.0\annotations-15.0.jar;C:\Users\PatrickF\.m2\repository\net\markenwerk\utils-lrucache\1.0.1\utils-lrucache-1.0.1.jar;C:\Users\PatrickF\.m2\repository\org\hashids\hashids\1.0.3\hashids-1.0.3.jar org.openjdk.jmh.Main at.favre.lib.idmaskbench.EncodingBenchmark.*
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.base32Decoding1024Byte
# Run progress: 0,00% complete, ETA 00:07:48
# Fork: 1 of 1
# Warmup Iteration 1: 3952,216 ns/op
# Warmup Iteration 2: 3865,009 ns/op
Iteration 1: 3852,466 ns/op
Iteration 2: 3838,781 ns/op
Iteration 3: 3837,373 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.base32Decoding1024Byte":
3842,873 ±(99.9%) 152,101 ns/op [Average]
(min, avg, max) = (3837,373, 3842,873, 3852,466), stdev = 8,337
CI (99.9%): [3690,772, 3994,974] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.base32Decoding16Byte
# Run progress: 5,56% complete, ETA 00:07:32
# Fork: 1 of 1
# Warmup Iteration 1: 103,663 ns/op
# Warmup Iteration 2: 101,193 ns/op
Iteration 1: 101,327 ns/op
Iteration 2: 101,144 ns/op
Iteration 3: 101,328 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.base32Decoding16Byte":
101,266 ±(99.9%) 1,932 ns/op [Average]
(min, avg, max) = (101,144, 101,266, 101,328), stdev = 0,106
CI (99.9%): [99,333, 103,198] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.base32Decoding8Byte
# Run progress: 11,11% complete, ETA 00:07:04
# Fork: 1 of 1
# Warmup Iteration 1: 72,636 ns/op
# Warmup Iteration 2: 69,647 ns/op
Iteration 1: 68,590 ns/op
Iteration 2: 68,572 ns/op
Iteration 3: 68,516 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.base32Decoding8Byte":
68,560 ±(99.9%) 0,703 ns/op [Average]
(min, avg, max) = (68,516, 68,560, 68,590), stdev = 0,039
CI (99.9%): [67,856, 69,263] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.base32Encoding1024Byte
# Run progress: 16,67% complete, ETA 00:06:37
# Fork: 1 of 1
# Warmup Iteration 1: 6881,818 ns/op
# Warmup Iteration 2: 6870,477 ns/op
Iteration 1: 6982,777 ns/op
Iteration 2: 6979,930 ns/op
Iteration 3: 6975,443 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.base32Encoding1024Byte":
6979,384 ±(99.9%) 67,456 ns/op [Average]
(min, avg, max) = (6975,443, 6979,384, 6982,777), stdev = 3,697
CI (99.9%): [6911,927, 7046,840] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.base32Encoding16Byte
# Run progress: 22,22% complete, ETA 00:06:10
# Fork: 1 of 1
# Warmup Iteration 1: 132,634 ns/op
# Warmup Iteration 2: 132,234 ns/op
Iteration 1: 130,916 ns/op
Iteration 2: 130,852 ns/op
Iteration 3: 130,943 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.base32Encoding16Byte":
130,904 ±(99.9%) 0,856 ns/op [Average]
(min, avg, max) = (130,852, 130,904, 130,943), stdev = 0,047
CI (99.9%): [130,048, 131,760] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.base32Encoding8Byte
# Run progress: 27,78% complete, ETA 00:05:44
# Fork: 1 of 1
# Warmup Iteration 1: 91,267 ns/op
# Warmup Iteration 2: 89,826 ns/op
Iteration 1: 88,768 ns/op
Iteration 2: 88,818 ns/op
Iteration 3: 88,785 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.base32Encoding8Byte":
88,790 ±(99.9%) 0,461 ns/op [Average]
(min, avg, max) = (88,768, 88,790, 88,818), stdev = 0,025
CI (99.9%): [88,329, 89,252] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.base64Decoding1024Byte
# Run progress: 33,33% complete, ETA 00:05:17
# Fork: 1 of 1
# Warmup Iteration 1: 1940,867 ns/op
# Warmup Iteration 2: 1920,065 ns/op
Iteration 1: 1938,945 ns/op
Iteration 2: 1915,427 ns/op
Iteration 3: 1925,898 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.base64Decoding1024Byte":
1926,757 ±(99.9%) 214,951 ns/op [Average]
(min, avg, max) = (1915,427, 1926,757, 1938,945), stdev = 11,782
CI (99.9%): [1711,805, 2141,708] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.base64Decoding16Byte
# Run progress: 38,89% complete, ETA 00:04:51
# Fork: 1 of 1
# Warmup Iteration 1: 50,550 ns/op
# Warmup Iteration 2: 50,571 ns/op
Iteration 1: 49,993 ns/op
Iteration 2: 50,409 ns/op
Iteration 3: 49,986 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.base64Decoding16Byte":
50,129 ±(99.9%) 4,415 ns/op [Average]
(min, avg, max) = (49,986, 50,129, 50,409), stdev = 0,242
CI (99.9%): [45,714, 54,545] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.base64Decoding8Byte
# Run progress: 44,44% complete, ETA 00:04:24
# Fork: 1 of 1
# Warmup Iteration 1: 43,179 ns/op
# Warmup Iteration 2: 42,938 ns/op
Iteration 1: 43,553 ns/op
Iteration 2: 43,523 ns/op
Iteration 3: 43,284 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.base64Decoding8Byte":
43,453 ±(99.9%) 2,694 ns/op [Average]
(min, avg, max) = (43,284, 43,453, 43,553), stdev = 0,148
CI (99.9%): [40,760, 46,147] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.base64Encoding1024Byte
# Run progress: 50,00% complete, ETA 00:03:58
# Fork: 1 of 1
# Warmup Iteration 1: 2095,753 ns/op
# Warmup Iteration 2: 2078,084 ns/op
Iteration 1: 1977,184 ns/op
Iteration 2: 1987,028 ns/op
Iteration 3: 1992,939 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.base64Encoding1024Byte":
1985,717 ±(99.9%) 145,202 ns/op [Average]
(min, avg, max) = (1977,184, 1985,717, 1992,939), stdev = 7,959
CI (99.9%): [1840,515, 2130,919] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.base64Encoding16Byte
# Run progress: 55,56% complete, ETA 00:03:31
# Fork: 1 of 1
# Warmup Iteration 1: 73,888 ns/op
# Warmup Iteration 2: 72,767 ns/op
Iteration 1: 73,680 ns/op
Iteration 2: 73,566 ns/op
Iteration 3: 73,426 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.base64Encoding16Byte":
73,557 ±(99.9%) 2,330 ns/op [Average]
(min, avg, max) = (73,426, 73,557, 73,680), stdev = 0,128
CI (99.9%): [71,228, 75,887] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.base64Encoding8Byte
# Run progress: 61,11% complete, ETA 00:03:05
# Fork: 1 of 1
# Warmup Iteration 1: 56,017 ns/op
# Warmup Iteration 2: 54,809 ns/op
Iteration 1: 54,054 ns/op
Iteration 2: 54,017 ns/op
Iteration 3: 54,444 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.base64Encoding8Byte":
54,172 ±(99.9%) 4,318 ns/op [Average]
(min, avg, max) = (54,017, 54,172, 54,444), stdev = 0,237
CI (99.9%): [49,854, 58,490] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.hexDecoding1024Byte
# Run progress: 66,67% complete, ETA 00:02:38
# Fork: 1 of 1
# Warmup Iteration 1: 2670,816 ns/op
# Warmup Iteration 2: 2648,065 ns/op
Iteration 1: 2664,331 ns/op
Iteration 2: 2662,089 ns/op
Iteration 3: 2671,584 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.hexDecoding1024Byte":
2666,002 ±(99.9%) 90,547 ns/op [Average]
(min, avg, max) = (2662,089, 2666,002, 2671,584), stdev = 4,963
CI (99.9%): [2575,454, 2756,549] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.hexDecoding16Byte
# Run progress: 72,22% complete, ETA 00:02:12
# Fork: 1 of 1
# Warmup Iteration 1: 63,607 ns/op
# Warmup Iteration 2: 61,977 ns/op
Iteration 1: 63,486 ns/op
Iteration 2: 63,715 ns/op
Iteration 3: 63,664 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.hexDecoding16Byte":
63,622 ±(99.9%) 2,197 ns/op [Average]
(min, avg, max) = (63,486, 63,622, 63,715), stdev = 0,120
CI (99.9%): [61,425, 65,819] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.hexDecoding8Byte
# Run progress: 77,78% complete, ETA 00:01:45
# Fork: 1 of 1
# Warmup Iteration 1: 43,157 ns/op
# Warmup Iteration 2: 42,754 ns/op
Iteration 1: 43,194 ns/op
Iteration 2: 43,214 ns/op
Iteration 3: 43,018 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.hexDecoding8Byte":
43,142 ±(99.9%) 1,964 ns/op [Average]
(min, avg, max) = (43,018, 43,142, 43,214), stdev = 0,108
CI (99.9%): [41,178, 45,106] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.hexEncoding1024Byte
# Run progress: 83,33% complete, ETA 00:01:19
# Fork: 1 of 1
# Warmup Iteration 1: 3048,906 ns/op
# Warmup Iteration 2: 3007,266 ns/op
Iteration 1: 3019,249 ns/op
Iteration 2: 3003,848 ns/op
Iteration 3: 3005,544 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.hexEncoding1024Byte":
3009,547 ±(99.9%) 154,068 ns/op [Average]
(min, avg, max) = (3003,848, 3009,547, 3019,249), stdev = 8,445
CI (99.9%): [2855,479, 3163,615] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.hexEncoding16Byte
# Run progress: 88,89% complete, ETA 00:00:52
# Fork: 1 of 1
# Warmup Iteration 1: 69,446 ns/op
# Warmup Iteration 2: 65,099 ns/op
Iteration 1: 63,651 ns/op
Iteration 2: 63,757 ns/op
Iteration 3: 63,769 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.hexEncoding16Byte":
63,725 ±(99.9%) 1,185 ns/op [Average]
(min, avg, max) = (63,651, 63,725, 63,769), stdev = 0,065
CI (99.9%): [62,540, 64,911] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_202, OpenJDK 64-Bit Server VM, 25.202-b08
# VM invoker: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\bin\java.exe
# VM options: -Dfile.encoding=UTF-8
# Warmup: 2 iterations, 4 s each
# Measurement: 3 iterations, 6 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: at.favre.lib.idmaskbench.EncodingBenchmark.hexEncoding8Byte
# Run progress: 94,44% complete, ETA 00:00:26
# Fork: 1 of 1
# Warmup Iteration 1: 44,623 ns/op
# Warmup Iteration 2: 43,952 ns/op
Iteration 1: 43,233 ns/op
Iteration 2: 43,214 ns/op
Iteration 3: 43,204 ns/op
Result "at.favre.lib.idmaskbench.EncodingBenchmark.hexEncoding8Byte":
43,217 ±(99.9%) 0,271 ns/op [Average]
(min, avg, max) = (43,204, 43,217, 43,233), stdev = 0,015
CI (99.9%): [42,947, 43,488] (assumes normal distribution)
# Run complete. Total time: 00:07:56
REMEMBER: The numbers below are just data. To gain reusable insights, you need to follow up on
why the numbers are the way they are. Use profilers (see -prof, -lprof), design factorial
experiments, perform baseline and negative tests that provide experimental control, make sure
the benchmarking environment is safe on JVM/OS/HW level, ask for reviews from the domain experts.
Do not assume the numbers tell you what you want them to tell.
Benchmark Mode Cnt Score Error Units
EncodingBenchmark.base32Decoding1024Byte avgt 3 3842,873 ± 152,101 ns/op
EncodingBenchmark.base32Decoding16Byte avgt 3 101,266 ± 1,932 ns/op
EncodingBenchmark.base32Decoding8Byte avgt 3 68,560 ± 0,703 ns/op
EncodingBenchmark.base32Encoding1024Byte avgt 3 6979,384 ± 67,456 ns/op
EncodingBenchmark.base32Encoding16Byte avgt 3 130,904 ± 0,856 ns/op
EncodingBenchmark.base32Encoding8Byte avgt 3 88,790 ± 0,461 ns/op
EncodingBenchmark.base64Decoding1024Byte avgt 3 1926,757 ± 214,951 ns/op
EncodingBenchmark.base64Decoding16Byte avgt 3 50,129 ± 4,415 ns/op
EncodingBenchmark.base64Decoding8Byte avgt 3 43,453 ± 2,694 ns/op
EncodingBenchmark.base64Encoding1024Byte avgt 3 1985,717 ± 145,202 ns/op
EncodingBenchmark.base64Encoding16Byte avgt 3 73,557 ± 2,330 ns/op
EncodingBenchmark.base64Encoding8Byte avgt 3 54,172 ± 4,318 ns/op
EncodingBenchmark.hexDecoding1024Byte avgt 3 2666,002 ± 90,547 ns/op
EncodingBenchmark.hexDecoding16Byte avgt 3 63,622 ± 2,197 ns/op
EncodingBenchmark.hexDecoding8Byte avgt 3 43,142 ± 1,964 ns/op
EncodingBenchmark.hexEncoding1024Byte avgt 3 3009,547 ± 154,068 ns/op
EncodingBenchmark.hexEncoding16Byte avgt 3 63,725 ± 1,185 ns/op
EncodingBenchmark.hexEncoding8Byte avgt 3 43,217 ± 0,271 ns/op
Process finished with exit code 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment