Skip to content

Commit

Permalink
Fix output of main class.
Browse files Browse the repository at this point in the history
  • Loading branch information
wrandelshofer committed Oct 13, 2024
1 parent 4202960 commit c95fc91
Showing 1 changed file with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,21 @@ public static void main(String... args) throws Exception {
Main benchmark = new Main();
for (int i = 0; i < args.length; i++) {
switch (args[i]) {
case "--markdown":
benchmark.markdown = true;
break;
case "--sleep":
benchmark.sleep = true;
break;
case "--print-confidence":
benchmark.printConfidence = true;
break;
case "--markdown":
benchmark.markdown = true;
break;
case "--sleep":
benchmark.sleep = true;
break;
case "--print-confidence":
benchmark.printConfidence = true;
break;
case "--locale":
benchmark.locale = Locale.forLanguageTag(args[++i]);
break;
default:
benchmark.filename = args[i];
break;
default:
benchmark.filename = args[i];
break;
}
}

Expand Down Expand Up @@ -163,8 +163,8 @@ private Map<String, BenchmarkFunction> createBenchmarkFunctions(List<String> lin
new BenchmarkFunction("JavaBigDecimalParser char[]", "java.math.BigDecimal", () -> sumFastBigDecimalFromCharArray(charArrayLines)),
new BenchmarkFunction("JavaBigDecimalParser byte[]", "java.math.BigDecimal", () -> sumFastBigDecimalFromByteArray(byteArrayLines)),

new BenchmarkFunction("ConfigurableDoubleParser CharSequence", "java.text.NumberFormat", () -> sumLenientDoubleFromCharSequence(lines)),
new BenchmarkFunction("ConfigurableDoubleParser char[]", "java.text.NumberFormat", () -> sumLenientDoubleFromCharArray(charArrayLines))
new BenchmarkFunction("ConfigurableDoubleParser CharSequence", "java.text.NumberFormat", () -> sumConfigurableDoubleFromCharSequence(lines)),
new BenchmarkFunction("ConfigurableDoubleParser char[]", "java.text.NumberFormat", () -> sumConfigurableDoubleFromCharArray(charArrayLines))

);
for (BenchmarkFunction b : benchmarkFunctions) {
Expand Down Expand Up @@ -225,7 +225,7 @@ private void printStatsAscii(List<String> lines, double volumeMB, String name, V
if (printConfidence) {
double confidenceWidth = Stats.confidence(1 - confidenceLevel, stats.getSampleStandardDeviation(), stats.getCount()) / stats.getAverage();

System.out.printf("%-33s : %7.2f MB/s (+/-%4.1f %% stdv) (+/-%4.1f %% conf, %6d trials) %7.2f Mfloat/s %7.2f ns/f %4.2f %s %s\n",
System.out.printf("%-40s : %7.2f MB/s (+/-%4.1f %% stdv) (+/-%4.1f %% conf, %6d trials) %7.2f Mfloat/s %7.2f ns/f %4.2f %s %s\n",
name,
volumeMB * 1e9 / stats.getAverage(),
stats.getSampleStandardDeviation() * 100 / stats.getAverage(),
Expand All @@ -238,7 +238,7 @@ private void printStatsAscii(List<String> lines, double volumeMB, String name, V
baselines.get(reference)
);
} else {
System.out.printf("%-33s : %7.2f MB/s (+/-%4.1f %%) %7.2f Mfloat/s %9.2f ns/f %7.2f %s %s\n",
System.out.printf("%-40s : %7.2f MB/s (+/-%4.1f %%) %7.2f Mfloat/s %9.2f ns/f %7.2f %s %s\n",
name,
volumeMB * 1e9 / stats.getAverage(),
stats.getSampleStandardDeviation() * 100 / stats.getAverage(),
Expand All @@ -264,16 +264,16 @@ private static double computeSpeedup(String name, VarianceStatistics stats, Map<
}

private void printStatsHeaderMarkdown() {
System.out.println("|Method | MB/s |stdev|Mfloats/s| ns/f | speedup | JDK |");
System.out.println("|---------------------------------|------:|-----:|------:|--------:|--------:|--------|");
System.out.println("|Method | MB/s |stdev|Mfloats/s| ns/f | speedup | JDK |");
System.out.println("|----------------------------------------|------:|-----:|------:|--------:|--------:|--------|");
}

private void printStatsMarkdown(List<String> lines, double volumeMB, String name, VarianceStatistics stats, Map<String, BenchmarkFunction> functions, Map<String, VarianceStatistics> results, Map<String, Character> baselines) {
double speedup = computeSpeedup(name, stats, functions, results);
String reference = functions.get(name).reference;
boolean isBaseline = reference.equals(name);
String speedupOrBaseline = isBaseline ? "=" : "*";
System.out.printf("|%-33s|%7.2f|%4.1f %%|%7.2f|%9.2f|%7.2f%s%s|%-8s|\n",
System.out.printf("|%-40s|%7.2f|%4.1f %%|%7.2f|%9.2f|%7.2f%s%s|%-8s|\n",
name,
volumeMB * 1e9 / stats.getAverage(),
stats.getSampleStandardDeviation() * 100 / stats.getAverage(),
Expand Down Expand Up @@ -474,7 +474,7 @@ private float sumFastFloatParserFromCharArray(List<char[]> s) {
return answer;
}

private double sumLenientDoubleFromCharSequence(List<String> s) {
private double sumConfigurableDoubleFromCharSequence(List<String> s) {
double answer = 0;
ConfigurableDoubleParser p = new ConfigurableDoubleParser(((DecimalFormat)
NumberFormat.getInstance(locale)).getDecimalFormatSymbols());
Expand All @@ -485,7 +485,7 @@ private double sumLenientDoubleFromCharSequence(List<String> s) {
return answer;
}

private double sumLenientDoubleFromCharArray(List<char[]> s) {
private double sumConfigurableDoubleFromCharArray(List<char[]> s) {
double answer = 0;
ConfigurableDoubleParser p = new ConfigurableDoubleParser(((DecimalFormat)
NumberFormat.getInstance(locale)).getDecimalFormatSymbols());
Expand Down

0 comments on commit c95fc91

Please sign in to comment.