PDF
Contents1使JMHBenchmarkContentsgroup 'riguz'version '1.0-SNAPSHOT'apply plugin: 'java'sourceCompatibility = 1.8sourceSets { jmh}repositories { mavenCentral()}dependencies { jmhCompile project jmhCompile 'org.openjdk.jmh:jmh-core:1.21' jmhCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.21' jmhCompile group: 'junit', name: 'junit', version: '4.12' testCompile group: 'junit', name: 'junit', version: '4.12'}task jmh(type: JavaExec, description: 'Executing JMH benchmarks') { classpath = sourceSets.jmh.runtimeClasspath main = 'org.openjdk.jmh.Main'}@Benchmark @Warmup(iterations = 1, time = 5) @Measurement(iterations = 1, time = 5) public void encodeWithJdk() { final byte[] bytes = Dream.text.getBytes(); byte[] encoded = Base64.getEncoder().encode(bytes); byte[] decoded = Base64.getDecoder().decode(encoded); assertTrue(Arrays.equals(bytes, decoded)); } @Benchmark @Warmup(iterations = 1, time = 5) @Measurement(iterations = 1, time = 5) Contents2 public void encodeWithBase64Codec() throws IOException { final byte[] bytes = Dream.text.getBytes(); byte[] encoded = Base64Codec.encodeToByte(bytes, true); byte[] decoded = Base64Codec.decodeFast(encoded, encoded.length); assertTrue(Arrays.equals(bytes, decoded)); }Benchmark Mode Cnt Score Error UnitsBase64BenchMark.encodeWithBase64Codec thrpt 5 15.296 ± 2.538 ops/sBase64BenchMark.encodeWithJdk thrpt 5 13.029 ± 1.563 ops/s

HTML view coming soon.

Download PDF for the full formatted version.