Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
liyuheng55555 committed Mar 15, 2024
1 parent 1c0094b commit 09adf96
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;

public abstract class BaseMode {
Expand Down Expand Up @@ -131,7 +132,8 @@ public void run() {
operations);
}
};
middleMeasureTimer.schedule(measure, 0, config.getRESULT_PRINT_INTERVAL() * 1000L);
middleMeasureTimer.schedule(
measure, TimeUnit.SECONDS.toMillis(1), config.getRESULT_PRINT_INTERVAL() * 1000L);
}

protected abstract void postCheck();
Expand Down Expand Up @@ -196,7 +198,8 @@ protected static void finalMeasure(
allClientsMeasurement,
startTime,
operations,
"All dataClients finished. The final test result is: ");
"All dataClients finished. The final test result is: ",
true);
}

protected static void middleMeasure(
Expand All @@ -209,22 +212,26 @@ protected static void middleMeasure(
allClientsMeasurement,
startTime,
operations,
"The test is in progress. The current test result is: ");
"The test is in progress. The current test result is: ",
false);
}

private static void measure(
Measurement measurement,
Stream<Measurement> allClientsMeasurement,
long startTime,
List<Operation> operations,
String prefix) {
String prefix,
boolean needPrintConf) {
measurement.setElapseTime((System.nanoTime() - startTime) / NANO_TO_SECOND);
// sum up all the measurements and calculate statistics
measurement.resetMeasurementMaps();
allClientsMeasurement.forEach(measurement::mergeMeasurement);
// output results
String showMeasurement = prefix;
showMeasurement += measurement.getConfigsString();
if (needPrintConf) {
showMeasurement += measurement.getConfigsString();
}
if (config.isUSE_MEASUREMENT()) {
// must call calculateMetrics() before using the Metrics
try {
Expand Down

0 comments on commit 09adf96

Please sign in to comment.