You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Base64 files, you described that if you don't use JAXB, then will fallback to SDK implementation which may be less performant. So, I tested this. I tested which is the faster one between CodecUtils and DataTypeConverter. As described comment on function, DataTypeConverter should be faster than CodecUtils. But, DataTypeConverter always slower than CodecUtils.
Expected Behavior
DataTypeCoverter is better than CodecUtils. (But Always lose)
Current Behavior
DataTypeCoverter is always slower than CodecUtils.
Reproduction Steps
classLearningTest : FunSpec({
test("which is faster?") {
val codec = Base64Codec()
// initialize Base64 Class because we have to execute static block code before testingClass.forName("com.amazonaws.util.Base64")
Class.forName("javax.xml.bind.DatatypeConverter");
// 1. DatatypeConverterval usingDatatypeConverter = measureNanoTime {
DatatypeConverter.printBase64Binary(byteArrayOf(
-86,
24,
85,
104,
67,
51,
80,
-80,
-68,
-48,
-35,
28,
1,
-92,
-43,
110
))
}
val hello = measureNanoTime { println("Hello") }
// 2. CodecUtils.toStringDirectval usingCodeUtils = measureNanoTime {
CodecUtils.toStringDirect(
codec.encode(
byteArrayOf(
-86,
24,
85,
104,
67,
51,
80,
-80,
-68,
-48,
-35,
28,
1,
-92,
-43,
110
)
)
)
}
println("usingDatatypeConverter: $usingDatatypeConverter") // 6455000
println("usingCodeUtils: $usingCodeUtils") // 386000
println("hello: $hello") // 30417// usingBase64 is faster than usingCodeUtils (fail)
usingCodeUtils.shouldBeGreaterThan(usingDatatypeConverter)
}
})
LOG.warn("JAXB is unavailable. Will fallback to SDK implementation which may be less performant." +
"If you are using Java 9+, you will need to include javax.xml.bind:jaxb-api as a dependency.");
publicstaticStringencodeAsString(byte... bytes) {
if (bytes == null) {
returnnull;
}
if (isJaxbAvailable) {
try {
returnDatatypeConverter.printBase64Binary(bytes);
} catch (NullPointerExceptionex) {
// https://netbeans.org/bugzilla/show_bug.cgi?id=224923// https://issues.apache.org/jira/browse/CAMEL-4893// Note the converter should eventually be initialized and printBase64Binary should start working againLOG.debug("Recovering from JAXB bug: https://netbeans.org/bugzilla/show_bug.cgi?id=224923", ex);
}
}
returnbytes.length == 0 ? "" : CodecUtils.toStringDirect(codec.encode(bytes));
}
High performant(DataTypeConverter)
Less performant(CodecUtils)
According to the comment in this file, DataTypeConverter should be faster than CodecUtils.
However, when I tested it, CodecUtils was always faster than DataTypeConverter.
Describe the bug
https://github.com/aws/aws-sdk-java/blob/8542b3ddc6be843dc910b3ccb1e6aeb3cc05c001/aws-java-sdk-core/src/main/java/com/amazonaws/util/Base64.java
In Base64 files, you described that if you don't use
JAXB
, then will fallback to SDK implementation which may be less performant. So, I tested this. I tested which is the faster one between CodecUtils and DataTypeConverter. As described comment on function, DataTypeConverter should be faster than CodecUtils. But, DataTypeConverter always slower than CodecUtils.Expected Behavior
DataTypeCoverter is better than CodecUtils. (But Always lose)
Current Behavior
DataTypeCoverter is always slower than CodecUtils.
Reproduction Steps
Possible Solution
No response
Additional Information/Context
AWS Java SDK version used
1.12.174
JDK version used
17
Operating System and version
macOS monterey 12.6 (21G115) M1Max Memory: 32GB
The text was updated successfully, but these errors were encountered: