Skip to content

Commit 1917188

Browse files
committed
Remove unused benchmark code.
Was moved to https://github.com/patrickfav/benchmark-jmh-sandbox
1 parent 6c355b2 commit 1917188

File tree

2 files changed

+22
-211
lines changed

2 files changed

+22
-211
lines changed

src/test/java/at/favre/lib/bytes/EncodingJmhBenchmark.java renamed to src/test/java/at/favre/lib/bytes/EncodingBase64JmhBenchmark.java

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,19 @@
5959
@Measurement(iterations = 4, time = 5)
6060
@BenchmarkMode(Mode.Throughput)
6161
@OutputTimeUnit(TimeUnit.SECONDS)
62-
public class EncodingJmhBenchmark {
62+
public class EncodingBase64JmhBenchmark {
6363

6464
@Param({"1", "16", "128", "512", "1000000"})
6565
private int byteLength;
6666
private Map<Integer, Bytes[]> rndMap;
6767

6868
private BinaryToTextEncoding.EncoderDecoder base64Okio;
69-
private BinaryToTextEncoding.EncoderDecoder base64Guava;
70-
private BinaryToTextEncoding.EncoderDecoder base64Apache;
7169
private Random random;
7270

7371
@Setup(Level.Trial)
7472
public void setup() {
7573
random = new Random();
7674
base64Okio = new BinaryToTextEncoding.Base64Encoding();
77-
// base64Apache = new ApacheCommonCodecBase64();
78-
// base64Guava = new GuavaBase64();
7975

8076
rndMap = new HashMap<>();
8177
int[] lengths = new int[]{1, 16, 128, 512, 1000000};
@@ -93,58 +89,11 @@ public byte[] encodeBase64Okio() {
9389
return encodeDecode(base64Okio);
9490
}
9591

96-
// @Benchmark
97-
// public byte[] encodeBase64Apache() {
98-
// return encodeDecode(base64Apache);
99-
// }
100-
//
101-
// @Benchmark
102-
// public byte[] encodeBase64Guava() {
103-
// return encodeDecode(base64Guava);
104-
// }
105-
10692
private byte[] encodeDecode(BinaryToTextEncoding.EncoderDecoder encoder) {
10793
Bytes[] bytes = rndMap.get(byteLength);
10894
int rndNum = random.nextInt(bytes.length);
10995

11096
String encoded = encoder.encode(bytes[rndNum].array(), ByteOrder.BIG_ENDIAN);
11197
return encoder.decode(encoded);
11298
}
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-
// }
15099
}

src/test/java/at/favre/lib/bytes/EncodingHexJmhBenchmark.java

Lines changed: 21 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,6 @@ public class EncodingHexJmhBenchmark {
128128
private BinaryToTextEncoding.EncoderDecoder option3;
129129
private BinaryToTextEncoding.EncoderDecoder option4;
130130
private BinaryToTextEncoding.EncoderDecoder option5;
131-
private BinaryToTextEncoding.EncoderDecoder option6;
132-
private BinaryToTextEncoding.EncoderDecoder option7;
133-
private BinaryToTextEncoding.EncoderDecoder option8;
134-
private BinaryToTextEncoding.EncoderDecoder option9;
135-
private BinaryToTextEncoding.EncoderDecoder option10;
136131
private Random random;
137132

138133
@Setup(Level.Trial)
@@ -144,11 +139,6 @@ public void setup() {
144139
option3 = new BigIntegerHexEncoder();
145140
option4 = new OldBytesImplementation();
146141
option5 = new StackOverflowAnswer2Encoder();
147-
// option6 = new BCUtilEncoder();
148-
// option7 = new GuavaEncoder();
149-
// option8 = new SpringSecurityEncoder();
150-
// option9 = new ApacheCommonsHex();
151-
// option10 = new JaxBDataTypeHex();
152142

153143
rndMap = new HashMap<>();
154144
int[] lengths = new int[]{4, 8, 16, 32, 128, 512, 1000000};
@@ -161,54 +151,29 @@ public void setup() {
161151
}
162152
}
163153

164-
// @Benchmark
165-
// public String encodeStackOverflowCode1() {
166-
// return encodeDecode(option1);
167-
// }
168-
//
169-
// @Benchmark
170-
// public String encodeBytesLib() {
171-
// return encodeDecode(option2);
172-
// }
173-
//
174-
// @Benchmark
175-
// public String encodeBigInteger() {
176-
// return encodeDecode(option3);
177-
// }
178-
//
179-
// @Benchmark
180-
// public String encodeOldBytesLib() {
181-
// return encodeDecode(option4);
182-
// }
183-
//
184-
// @Benchmark
185-
// public String encodeStackOverflowCode2() {
186-
// return encodeDecode(option5);
187-
// }
188-
//
189-
// @Benchmark
190-
// public String encodeBouncyCastleHex() {
191-
// return encodeDecode(option6);
192-
// }
193-
//
194-
// @Benchmark
195-
// public String encodeGuavaBase16() {
196-
// return encodeDecode(option7);
197-
// }
198-
//
199-
// @Benchmark
200-
// public String encodeSpringSecurity() {
201-
// return encodeDecode(option8);
202-
// }
203-
//
204-
// @Benchmark
205-
// public String encodeApacheCommons() {
206-
// return encodeDecode(option9);
207-
// }
154+
@Benchmark
155+
public String encodeStackOverflowCode1() {
156+
return encodeDecode(option1);
157+
}
158+
159+
@Benchmark
160+
public String encodeBytesLib() {
161+
return encodeDecode(option2);
162+
}
163+
164+
@Benchmark
165+
public String encodeBigInteger() {
166+
return encodeDecode(option3);
167+
}
208168

209169
@Benchmark
210-
public String encodeJaxBDataTypeConverter() {
211-
return encodeDecode(option10);
170+
public String encodeOldBytesLib() {
171+
return encodeDecode(option4);
172+
}
173+
174+
@Benchmark
175+
public String encodeStackOverflowCode2() {
176+
return encodeDecode(option5);
212177
}
213178

214179
private String encodeDecode(BinaryToTextEncoding.EncoderDecoder encoder) {
@@ -320,107 +285,4 @@ public byte[] decode(CharSequence encoded) {
320285
throw new UnsupportedOperationException();
321286
}
322287
}
323-
324-
325-
326-
/*
327-
* Requires dependencies:
328-
*
329-
*
330-
*
331-
<dependency>
332-
<groupId>org.bouncycastle</groupId>
333-
<artifactId>bcprov-jdk15on</artifactId>
334-
<version>1.60</version>
335-
<scope>test</scope>
336-
</dependency>
337-
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
338-
<dependency>
339-
<groupId>com.google.guava</groupId>
340-
<artifactId>guava</artifactId>
341-
<version>28.1-jre</version>
342-
<scope>test</scope>
343-
</dependency>
344-
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-core -->
345-
<dependency>
346-
<groupId>org.springframework.security</groupId>
347-
<artifactId>spring-security-core</artifactId>
348-
<version>5.2.0.RELEASE</version>
349-
<scope>test</scope>
350-
</dependency>
351-
<dependency>
352-
<groupId>commons-codec</groupId>
353-
<artifactId>commons-codec</artifactId>
354-
<version>1.13</version>
355-
</dependency>
356-
<dependency>
357-
<groupId>javax.xml.bind</groupId>
358-
<artifactId>jaxb-api</artifactId>
359-
<version>2.3.1</version>
360-
</dependency>
361-
*/
362-
363-
// static final class ApacheCommonsHex implements BinaryToTextEncoding.EncoderDecoder {
364-
// @Override
365-
// public String encode(byte[] array, ByteOrder byteOrder) {
366-
// return org.apache.commons.codec.binary.Hex.encodeHexString(array);
367-
// }
368-
//
369-
// @Override
370-
// public byte[] decode(CharSequence encoded) {
371-
// try {
372-
// return Hex.decodeHex(encoded.toString());
373-
// } catch (DecoderException e) {
374-
// throw new RuntimeException(e);
375-
// }
376-
// }
377-
// }
378-
//
379-
// static final class BCUtilEncoder implements BinaryToTextEncoding.EncoderDecoder {
380-
// @Override
381-
// public String encode(byte[] array, ByteOrder byteOrder) {
382-
// return org.bouncycastle.util.encoders.Hex.toHexString(array);
383-
// }
384-
//
385-
// @Override
386-
// public byte[] decode(CharSequence encoded) {
387-
// return org.bouncycastle.util.encoders.Hex.decode(encoded.toString());
388-
// }
389-
// }
390-
//
391-
// static final class GuavaEncoder implements BinaryToTextEncoding.EncoderDecoder {
392-
// @Override
393-
// public String encode(byte[] array, ByteOrder byteOrder) {
394-
// return com.google.common.io.BaseEncoding.base16().lowerCase().encode(array);
395-
// }
396-
//
397-
// @Override
398-
// public byte[] decode(CharSequence encoded) {
399-
// return com.google.common.io.BaseEncoding.base16().lowerCase().decode(encoded);
400-
// }
401-
// }
402-
//
403-
// static final class SpringSecurityEncoder implements BinaryToTextEncoding.EncoderDecoder {
404-
// @Override
405-
// public String encode(byte[] array, ByteOrder byteOrder) {
406-
// return new String(org.springframework.security.crypto.codec.Hex.encode(array));
407-
// }
408-
//
409-
// @Override
410-
// public byte[] decode(CharSequence encoded) {
411-
// return org.springframework.security.crypto.codec.Hex.decode(encoded);
412-
// }
413-
// }
414-
//
415-
// static final class JaxBDataTypeHex implements BinaryToTextEncoding.EncoderDecoder {
416-
// @Override
417-
// public String encode(byte[] array, ByteOrder byteOrder) {
418-
// return javax.xml.bind.DatatypeConverter.printHexBinary(array);
419-
// }
420-
//
421-
// @Override
422-
// public byte[] decode(CharSequence encoded) {
423-
// return javax.xml.bind.DatatypeConverter.parseHexBinary(encoded.toString());
424-
// }
425-
// }
426288
}

0 commit comments

Comments
 (0)