lindong28 commented on code in PR #87:
URL: https://github.com/apache/flink-ml/pull/87#discussion_r861680131
##########
flink-ml-benchmark/src/main/java/org/apache/flink/ml/benchmark/Benchmark.java:
##########
@@ -75,33 +75,43 @@ public static void printHelp() {
public static void executeBenchmarks(CommandLine commandLine) throws
Exception {
String configFile = commandLine.getArgs()[0];
Map<String, ?> benchmarks = BenchmarkUtils.parseJsonFile(configFile);
- System.out.println("Found benchmarks " + benchmarks.keySet());
+ System.out.println("Found " + benchmarks.keySet().size() + "
benchmarks.");
+ String saveFile =
commandLine.getOptionValue(OUTPUT_FILE_OPTION.getLongOpt());
StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment();
StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);
List<BenchmarkResult> results = new ArrayList<>();
+ String benchmarkResultsJson = "{}";
+ int index = 0;
for (Map.Entry<String, ?> benchmark : benchmarks.entrySet()) {
- LOG.info("Running benchmark " + benchmark.getKey() + ".");
+ LOG.info(
+ String.format(
+ "Running benchmark %d/%d: %s",
+ index++, benchmarks.keySet().size(),
benchmark.getKey()));
BenchmarkResult result =
BenchmarkUtils.runBenchmark(
tEnv, benchmark.getKey(), (Map<String, ?>)
benchmark.getValue());
results.add(result);
- LOG.info(BenchmarkUtils.getResultsMapAsJson(result));
- }
+ LOG.info("\n" + BenchmarkUtils.getResultsMapAsJson(result));
+
+ benchmarkResultsJson =
+ BenchmarkUtils.getResultsMapAsJson(results.toArray(new
BenchmarkResult[0]));
- String benchmarkResultsJson =
- BenchmarkUtils.getResultsMapAsJson(results.toArray(new
BenchmarkResult[0]));
+ if (commandLine.hasOption(OUTPUT_FILE_OPTION.getLongOpt())) {
+ ReadWriteUtils.saveToFile(saveFile, benchmarkResultsJson,
true);
Review Comment:
Hmm.. I think we can still save all benchmark results outside the loop, when
one benchmark fails, by catching the exception from the benchmark failure.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]