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
When running a microbenchmark with a benchmark class name of 5 characters, the following runtime exception occurs:
Exception in thread "main" java.lang.RuntimeException: java.util.FormatFlagsConversionMismatchException: Conversion = s, Flags = 0
at net.adoptopenjdk.bumblebench.core.Launcher.runBumbleMainOn(Launcher.java:64)
at net.adoptopenjdk.bumblebench.core.Launcher.main(Launcher.java:55)
Caused by: java.util.FormatFlagsConversionMismatchException: Conversion = s, Flags = 0
at java.base/java.util.Formatter$FormatSpecifier.failMismatch(Formatter.java:4511)
at java.base/java.util.Formatter$FormatSpecifier.checkBadFlags(Formatter.java:3276)
at java.base/java.util.Formatter$FormatSpecifier.checkGeneral(Formatter.java:3235)
at java.base/java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2999)
at java.base/java.util.Formatter.parse(Formatter.java:2849)
at java.base/java.util.Formatter.format(Formatter.java:2774)
at java.base/java.util.Formatter.format(Formatter.java:2728)
at java.base/java.lang.String.format(String.java:5162)
at net.adoptopenjdk.bumblebench.core.BumbleBench.run(BumbleBench.java:266)
at net.adoptopenjdk.bumblebench.core.MicroBench.run(MicroBench.java:107)
at net.adoptopenjdk.bumblebench.core.BumbleBench.bumbleMain(BumbleBench.java:287)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:586)
at net.adoptopenjdk.bumblebench.core.Launcher.runBumbleMainOn(Launcher.java:61)
... 1 more
This exception occurs in BumbleBench.run(), where the lines reporting the score and uncertainty at the end of the run are constructed and printed.
In order to ensure an aesthetic alignment of the two lines, a number of spaces are sometimes added to the beginning of the second line, as in this example:
Since %0s is not a valid string format specifier, if the class name is 5 characters long, we get a crash. Although obviously less significant, if the class name is 4 characters or less, we don't get a crash, but we also don't get the alignment that this code intends to produce. For example, here is the output for a benchmark with a 4 character name, Test:
Test score: 7955413.000000 (7.955M 1588.9%)
uncertainty: 1.1%
The following simple benchmark can reproduce this crash:
// Clone.javapackagenet.adoptopenjdk.bumblebench.stringcoding;
importnet.adoptopenjdk.bumblebench.core.MicroBench;
publicfinalclassCloneextendsMicroBench {
protectedlongdoBatch(longnumIterations) throwsInterruptedException {
for (longi = 0; i < numIterations; i++) {}
returnnumIterations;
}
}
The text was updated successfully, but these errors were encountered:
The following code would fix the crash and also ensure both lines are properly aligned no matter the length of the benchmark name. It can probably be cleaned up further, but I thought I would include it just as a starting point:
When running a microbenchmark with a benchmark class name of 5 characters, the following runtime exception occurs:
This exception occurs in
BumbleBench.run()
, where the lines reporting the score and uncertainty at the end of the run are constructed and printed.In order to ensure an aesthetic alignment of the two lines, a number of spaces are sometimes added to the beginning of the second line, as in this example:
However, the line of code which produces the correct number of spaces assumes that the name of the benchmark is at least 6 characters:
Since
%0s
is not a valid string format specifier, if the class name is 5 characters long, we get a crash. Although obviously less significant, if the class name is 4 characters or less, we don't get a crash, but we also don't get the alignment that this code intends to produce. For example, here is the output for a benchmark with a 4 character name,Test
:The following simple benchmark can reproduce this crash:
The text was updated successfully, but these errors were encountered: