diff options
author | Harald Musum <musum@verizonmedia.com> | 2021-06-18 09:11:57 +0200 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2021-06-18 09:11:57 +0200 |
commit | 4faf5c73fe5854cf01c664d9a013bc44800b9011 (patch) | |
tree | bf6e513b20dc4ec28d786309671734234e8bdd30 /config | |
parent | ee89cce742e9dd4deaece4ee121923543dacd3b0 (diff) |
Use nanoTime()
Diffstat (limited to 'config')
-rw-r--r-- | config/src/main/java/com/yahoo/vespa/config/benchmark/LoadTester.java | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/config/src/main/java/com/yahoo/vespa/config/benchmark/LoadTester.java b/config/src/main/java/com/yahoo/vespa/config/benchmark/LoadTester.java index 1695879625d..728648ad0cf 100644 --- a/config/src/main/java/com/yahoo/vespa/config/benchmark/LoadTester.java +++ b/config/src/main/java/com/yahoo/vespa/config/benchmark/LoadTester.java @@ -79,7 +79,7 @@ public class LoadTester { configs = readConfigs(configsList); defs = readDefs(defPath); List<LoadThread> threadList = new ArrayList<>(); - long start = System.currentTimeMillis(); + long startInNanos = System.nanoTime(); Metrics m = new Metrics(); for (int i = 0; i < threads; i++) { @@ -92,7 +92,7 @@ public class LoadTester { lt.join(); m.merge(lt.metrics); } - printOutput(start, threads, iterations, m); + printOutput(startInNanos, threads, iterations, m); } private Map<ConfigDefinitionKey, Tuple2<String, String[]>> readDefs(String defPath) throws IOException { @@ -122,9 +122,8 @@ public class LoadTester { return ret; } - private void printOutput(long start, long threads, long iterations, Metrics metrics) { - long stop = System.currentTimeMillis(); - float durSec = (float) (stop - start) / 1000f; + private void printOutput(long startInNanos, long threads, long iterations, Metrics metrics) { + float durSec = (float) (System.nanoTime() - startInNanos) / 1_000_000_000f; StringBuilder sb = new StringBuilder(); sb.append("#reqs/sec #avglatency #minlatency #maxlatency #failedrequests\n"); sb.append(((float) (iterations * threads)) / durSec).append(","); @@ -215,14 +214,13 @@ public class LoadTester { ConfigKey<?> configKey = createFull(reqKey.getName(), reqKey.getConfigId(), reqKey.getNamespace(), defContent.first); JRTClientConfigRequest request = createRequest(configKey, defContent.second); if (debug) System.out.println("# Requesting: " + reqKey); - long start = System.currentTimeMillis(); + long start = System.nanoTime(); target.invokeSync(request.getRequest(), 10.0); - long end = System.currentTimeMillis(); + long durationInMillis = (System.nanoTime() - start) / 1_000_000; if (request.isError()) { target = handleError(request, spec, target); } else { - long duration = end - start; - metrics.update(duration); + metrics.update(durationInMillis); } } } |