Skip to content

Commit

Permalink
Fix invalid json of benchmark output
Browse files Browse the repository at this point in the history
  • Loading branch information
ocadaruma committed Mar 7, 2024
1 parent a3f1419 commit 1b03705
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion benchmark/src/main/java/com/linecorp/decaton/benchmark/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static java.util.Collections.emptyList;

import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
Expand Down Expand Up @@ -95,6 +96,9 @@ public final class Main implements Callable<Integer> {
defaultValue = "text")
private String resultFormat;

@Option(names = "--file", description = "Result file to write output to. If not specified, output to stdout")
private Path resultFile;

@Option(names = "--file-name-only",
description = "Trim file paths in result from its path to filename only")
private boolean fileNameOnly;
Expand Down Expand Up @@ -167,7 +171,13 @@ public Integer call() throws Exception {
@SuppressWarnings("OptionalGetWithoutIsPresent")
BenchmarkResult sum = results.stream().reduce(BenchmarkResult::plus).get();
BenchmarkResult result = sum.div(results.size());
resultFormat.print(config, System.out, result);
if (resultFile != null) {
try (FileOutputStream fos = new FileOutputStream(resultFile.toFile())) {
resultFormat.print(config, fos, result);
}
} else {
resultFormat.print(config, System.out, result);
}
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions cb/run-bm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ function run_with_opts() {
--file-name-only \
--warmup 10000000 \
--param=decaton.max.pending.records=10000 \
"$@" \
>$tmp
--file=$tmp \
"$@"
mv $tmp $out_dir/$name-benchmark.json
}

Expand Down

0 comments on commit 1b03705

Please sign in to comment.