The string formatting code which constructs and prints the lines reporting the score and uncertainty at the end of a benchmark run can be found in BumbleBench.run(). 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%
This PR improves upon that string formatting code to remove any dependency on the length of the benchmark name to ensure alignment of the score and uncertainty lines and fix the runtime exception.
The string formatting code which constructs and prints the lines reporting the score and uncertainty at the end of a benchmark run can be found in BumbleBench.run(). 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
:This PR improves upon that string formatting code to remove any dependency on the length of the benchmark name to ensure alignment of the score and uncertainty lines and fix the runtime exception.