Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add elapsed and start time to json summary output #394

Merged
merged 7 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/main/java/com/oltpbenchmark/Results.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

public final class Results {

private final long start_ts;
bpkroth marked this conversation as resolved.
Show resolved Hide resolved
private final long nanoseconds;
private final int measuredRequests;
private final DistributionStatistics distributionStatistics;
Expand All @@ -40,8 +41,9 @@ public final class Results {
private final Histogram<TransactionType> retryDifferent = new Histogram<>(false);
private final Map<TransactionType, Histogram<String>> abortMessages = new HashMap<>();

public Results(long nanoseconds, int measuredRequests, DistributionStatistics distributionStatistics, final List<LatencyRecord.Sample> latencySamples) {
this.nanoseconds = nanoseconds;
public Results(long start_ts, long elapsed_nanoseconds, int measuredRequests, DistributionStatistics distributionStatistics, final List<LatencyRecord.Sample> latencySamples) {
bpkroth marked this conversation as resolved.
Show resolved Hide resolved
this.start_ts = start_ts;
this.nanoseconds = elapsed_nanoseconds;
this.measuredRequests = measuredRequests;
this.distributionStatistics = distributionStatistics;

Expand Down Expand Up @@ -98,6 +100,10 @@ public List<Sample> getLatencySamples() {
return latencySamples;
}

public long getStartTs() {
return start_ts;
}

public long getNanoseconds() {
return nanoseconds;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/oltpbenchmark/ThreadBench.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ private Results runRateLimitedMultiPhase() {

// long measureStart = start;

long start_ts = System.currentTimeMillis();
long start = System.nanoTime();
bpkroth marked this conversation as resolved.
Show resolved Hide resolved
long warmupStart = System.nanoTime();
long warmup = warmupStart;
Expand Down Expand Up @@ -314,7 +315,7 @@ private Results runRateLimitedMultiPhase() {
}
DistributionStatistics stats = DistributionStatistics.computeStatistics(latencies);

Results results = new Results(measureEnd - start, requests, stats, samples);
Results results = new Results(start_ts, measureEnd - start, requests, stats, samples);

// Compute transaction histogram
Set<TransactionType> txnTypes = new HashSet<>();
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/com/oltpbenchmark/util/ResultWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,21 @@ public void writeConfig(PrintStream os) throws ConfigurationException {
}

public void writeSummary(PrintStream os) {
Map<String, Object> summaryMap = new TreeMap<>();
Map<String, Object> summaryMap = new LinkedHashMap<>();
bpkroth marked this conversation as resolved.
Show resolved Hide resolved
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
Date now = new Date();
summaryMap.put("Start timestamp (milliseconds)", results.getStartTs());
summaryMap.put("Current Timestamp (milliseconds)", now.getTime());
summaryMap.put("Elapsed Time (nanoseconds)", results.getNanoseconds());
summaryMap.put("DBMS Type", dbType);
summaryMap.put("DBMS Version", collector.collectVersion());
summaryMap.put("Benchmark Type", benchType);
summaryMap.put("Latency Distribution", results.getDistributionStatistics().toMap());
summaryMap.put("Throughput (requests/second)", results.requestsPerSecondThroughput());
summaryMap.put("Goodput (requests/second)", results.requestsPerSecondGoodput());
for (String field : BENCHMARK_KEY_FIELD) {
summaryMap.put(field, expConf.getString(field));
}
summaryMap.put("Latency Distribution", results.getDistributionStatistics().toMap());
summaryMap.put("Throughput (requests/second)", results.requestsPerSecondThroughput());
summaryMap.put("Goodput (requests/second)", results.requestsPerSecondGoodput());
os.println(JSONUtil.format(JSONUtil.toJSONString(summaryMap)));
}

Expand Down