Skip to content

Commit

Permalink
Move to correct place
Browse files Browse the repository at this point in the history
  • Loading branch information
triceo committed Jan 15, 2025
1 parent 4c1a446 commit 387165d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
6 changes: 3 additions & 3 deletions scoredirector-benchmark.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ example=cloud_balancing

# How many forks to run each example with.
# Default is 10.
forks=1
forks=2

# How many warmup iterations to run each example with.
# Default is 5.
warmup_iterations=1
warmup_iterations=2

# How many measurement iterations to run each example with.
# Default is 5.
measurement_iterations=1
measurement_iterations=2

# Ratio of benchmark score error to benchmark score above which warnings will be output.
# The higher the threshold, the less reliable the benchmark score is.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ private static final class ResultCapturingOutputFormat implements OutputFormat {

private final Path resultsDirectory;
private final OutputFormat delegate;
private int expectedIterationCount = -1;
private int iterationsRemaining = -1;

public ResultCapturingOutputFormat(Path resultsDirectory, OutputFormat format) {
this.resultsDirectory = resultsDirectory;
Expand All @@ -71,26 +73,20 @@ public void iteration(BenchmarkParams benchParams, IterationParams params, int i
@Override
public void iterationResult(BenchmarkParams benchParams, IterationParams params, int iteration, IterationResult data) {
delegate.iterationResult(benchParams, params, iteration, data);
}

@Override
public void startBenchmark(BenchmarkParams benchParams) {
delegate.startBenchmark(benchParams);
}

@Override
public void endBenchmark(BenchmarkResult result) {
delegate.endBenchmark(result);
var jfrFile = findJfrFile(resultsDirectory.toFile());
if (jfrFile == null) {
return;
}
var unixTime = System.currentTimeMillis() / 1000;
var target = resultsDirectory.resolve(unixTime + "-" + jfrFile.getName());
try {
Files.copy(jfrFile.toPath(), target);
} catch (IOException e) {
throw new IllegalStateException(e);
iterationsRemaining--;
if (iterationsRemaining == 0) {
iterationsRemaining = expectedIterationCount;
var jfrFile = findJfrFile(resultsDirectory.toFile());
if (jfrFile == null) {
return;
}
var unixTime = System.currentTimeMillis() / 1000;
var target = resultsDirectory.resolve(unixTime + "-" + jfrFile.getName());
try {
Files.copy(jfrFile.toPath(), target);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
}

Expand All @@ -108,6 +104,18 @@ private static File findJfrFile(File file) {
return null;
}

@Override
public void startBenchmark(BenchmarkParams benchParams) {
expectedIterationCount = benchParams.getWarmup().getCount() + benchParams.getMeasurement().getCount();
iterationsRemaining = expectedIterationCount;
delegate.startBenchmark(benchParams);
}

@Override
public void endBenchmark(BenchmarkResult result) {
delegate.endBenchmark(result);
}

@Override
public void startRun() {
delegate.startRun();
Expand Down

0 comments on commit 387165d

Please sign in to comment.