3535# i7 7700K / 24G
3636
3737Benchmark (byteLength) Mode Cnt Score Error Units
38- EncodingJmhBenchmark.encodeBase64Guava 1 thrpt 4 10361634,745 ± 152739,710 ops/s
39- EncodingJmhBenchmark.encodeBase64Guava 16 thrpt 4 4360485,804 ± 44729,417 ops/s
40- EncodingJmhBenchmark.encodeBase64Guava 128 thrpt 4 790407,010 ± 8095,476 ops/s
41- EncodingJmhBenchmark.encodeBase64Guava 512 thrpt 4 192448,674 ± 2196,035 ops/s
42- EncodingJmhBenchmark.encodeBase64Guava 1000000 thrpt 4 102,780 ± 2,949 ops/s
43- EncodingJmhBenchmark.encodeBase64Okio 1 thrpt 4 12658987,399 ± 361955,366 ops/s
44- EncodingJmhBenchmark.encodeBase64Okio 16 thrpt 4 7059404,777 ± 293665,348 ops/s
45- EncodingJmhBenchmark.encodeBase64Okio 128 thrpt 4 1749131,031 ± 85915,325 ops/s
46- EncodingJmhBenchmark.encodeBase64Okio 512 thrpt 4 239764,488 ± 6204,540 ops/s
47- EncodingJmhBenchmark.encodeBase64Okio 1000000 thrpt 4 107,868 ± 0,569 ops/s
38+ Benchmark (byteLength) Mode Cnt Score Error Units
39+ EncodingJmhBenchmark.encodeBase64Apache 1 thrpt 4 1260664,187 ± 134162,595 ops/s
40+ EncodingJmhBenchmark.encodeBase64Apache 16 thrpt 4 1018969,264 ± 4008,839 ops/s
41+ EncodingJmhBenchmark.encodeBase64Apache 128 thrpt 4 470368,001 ± 6377,776 ops/s
42+ EncodingJmhBenchmark.encodeBase64Apache 512 thrpt 4 170623,614 ± 5243,433 ops/s
43+ EncodingJmhBenchmark.encodeBase64Apache 1000000 thrpt 4 102,602 ± 2,441 ops/s
44+ EncodingJmhBenchmark.encodeBase64Guava 1 thrpt 4 10961113,761 ± 2448198,032 ops/s
45+ EncodingJmhBenchmark.encodeBase64Guava 16 thrpt 4 6223639,376 ± 189028,495 ops/s
46+ EncodingJmhBenchmark.encodeBase64Guava 128 thrpt 4 1390184,429 ± 35982,746 ops/s
47+ EncodingJmhBenchmark.encodeBase64Guava 512 thrpt 4 343957,426 ± 10939,429 ops/s
48+ EncodingJmhBenchmark.encodeBase64Guava 1000000 thrpt 4 229,641 ± 5,811 ops/s
49+ EncodingJmhBenchmark.encodeBase64Okio 1 thrpt 4 12567622,970 ± 460318,474 ops/s
50+ EncodingJmhBenchmark.encodeBase64Okio 16 thrpt 4 6552615,163 ± 1382416,859 ops/s
51+ EncodingJmhBenchmark.encodeBase64Okio 128 thrpt 4 1640526,665 ± 375607,815 ops/s
52+ EncodingJmhBenchmark.encodeBase64Okio 512 thrpt 4 235282,079 ± 6631,560 ops/s
53+ EncodingJmhBenchmark.encodeBase64Okio 1000000 thrpt 4 103,728 ± 0,820 ops/s
4854 */
4955
5056@ State (Scope .Thread )
@@ -61,13 +67,16 @@ public class EncodingJmhBenchmark {
6167
6268 private BinaryToTextEncoding .EncoderDecoder base64Okio ;
6369 private BinaryToTextEncoding .EncoderDecoder base64Guava ;
70+ private BinaryToTextEncoding .EncoderDecoder base64Apache ;
6471 private Random random ;
6572
6673 @ Setup (Level .Trial )
6774 public void setup () {
6875 random = new Random ();
6976 base64Okio = new BinaryToTextEncoding .Base64Encoding ();
70- base64Guava = new BaseEncoding (new BaseEncoding .Alphabet ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" .toCharArray ()), BaseEncoding .BASE32_RFC4848_PADDING );
77+ // base64Apache = new ApacheCommonCodecBase64();
78+ // base64Guava = new GuavaBase64();
79+
7180 rndMap = new HashMap <>();
7281 int [] lengths = new int []{1 , 16 , 128 , 512 , 1000000 };
7382 for (int length : lengths ) {
@@ -84,10 +93,15 @@ public byte[] encodeBase64Okio() {
8493 return encodeDecode (base64Okio );
8594 }
8695
87- @ Benchmark
88- public byte [] encodeBase64Guava () {
89- return encodeDecode (base64Guava );
90- }
96+ // @Benchmark
97+ // public byte[] encodeBase64Apache() {
98+ // return encodeDecode(base64Apache);
99+ // }
100+ //
101+ // @Benchmark
102+ // public byte[] encodeBase64Guava() {
103+ // return encodeDecode(base64Guava);
104+ // }
91105
92106 private byte [] encodeDecode (BinaryToTextEncoding .EncoderDecoder encoder ) {
93107 Bytes [] bytes = rndMap .get (byteLength );
@@ -96,4 +110,41 @@ private byte[] encodeDecode(BinaryToTextEncoding.EncoderDecoder encoder) {
96110 String encoded = encoder .encode (bytes [rndNum ].array (), ByteOrder .BIG_ENDIAN );
97111 return encoder .decode (encoded );
98112 }
113+
114+ // <dependency>
115+ // <groupId>commons-codec</groupId>
116+ // <artifactId>commons-codec</artifactId>
117+ // <version>1.11</version>
118+ // <scope>test</scope>
119+ // </dependency>
120+ // <dependency>
121+ // <groupId>com.google.guava</groupId>
122+ // <artifactId>guava</artifactId>
123+ // <version>26.0-jre</version>
124+ // <scope>test</scope>
125+ // </dependency>
126+ //
127+ // static final class ApacheCommonCodecBase64 implements BinaryToTextEncoding.EncoderDecoder {
128+ // @Override
129+ // public String encode(byte[] array, ByteOrder byteOrder) {
130+ // return Base64.encodeBase64String(array);
131+ // }
132+ //
133+ // @Override
134+ // public byte[] decode(String encoded) {
135+ // return Base64.decodeBase64(encoded);
136+ // }
137+ // }
138+ //
139+ // static final class GuavaBase64 implements BinaryToTextEncoding.EncoderDecoder {
140+ // @Override
141+ // public String encode(byte[] array, ByteOrder byteOrder) {
142+ // return com.google.common.io.BaseEncoding.base64().encode(array);
143+ // }
144+ //
145+ // @Override
146+ // public byte[] decode(String encoded) {
147+ // return com.google.common.io.BaseEncoding.base64().decode(encoded);
148+ // }
149+ // }
99150}
0 commit comments