@@ -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