From bf1afb4a36895c2863484acf89a8eb50229346e1 Mon Sep 17 00:00:00 2001 From: Alex Stark Date: Wed, 20 May 2020 11:57:59 -0700 Subject: [PATCH] Correct mistaken ms to ns conversion change. PiperOrigin-RevId: 312526413 Change-Id: If9a16f26caf69e1f2c5f434114630dbfacd0c038 --- .../org/tensorflow/ovic/OvicBenchmarker.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tensorflow/lite/java/ovic/src/main/java/org/tensorflow/ovic/OvicBenchmarker.java b/tensorflow/lite/java/ovic/src/main/java/org/tensorflow/ovic/OvicBenchmarker.java index 49cf21debc5..839984cfc5d 100644 --- a/tensorflow/lite/java/ovic/src/main/java/org/tensorflow/ovic/OvicBenchmarker.java +++ b/tensorflow/lite/java/ovic/src/main/java/org/tensorflow/ovic/OvicBenchmarker.java @@ -57,19 +57,19 @@ public abstract class OvicBenchmarker { /** Total runtime in ns. */ protected double totalRuntimeNano = 0.0; /** Total allowed runtime in ms. */ - protected double wallTimeNano = 20000 * 30 * 1.0e6; + protected double wallTimeMilli = 20000 * 30.0; /** Record whether benchmark has started (used to skip the first image). */ protected boolean benchmarkStarted = false; /** * Initializes an {@link OvicBenchmarker} * - * @param wallTimeNano: a double number specifying the total amount of time to benchmark. + * @param wallTimeMilli: a double number specifying the total amount of time to benchmark. */ - public OvicBenchmarker(double wallTimeNano) { + protected OvicBenchmarker(double wallTimeMilli) { benchmarkStarted = false; totalRuntimeNano = 0.0; - this.wallTimeNano = wallTimeNano; + this.wallTimeMilli = wallTimeMilli; } /** Return the cumulative latency of all runs so far. */ @@ -79,13 +79,13 @@ public abstract class OvicBenchmarker { /** Check whether the benchmarker should stop. */ public Boolean shouldStop() { - if (totalRuntimeNano >= wallTimeNano) { + if ((totalRuntimeNano * 1.0 / 1e6) >= wallTimeMilli) { Log.e( TAG, - "Total runtime (ms) " - + (totalRuntimeNano * 1.0e-6) - + " exceeded wall-time " - + (wallTimeNano * 1.0e-6)); + "Total runtime " + + (totalRuntimeNano * 1.0 / 1e6) + + " exceeded walltime (ms) " + + wallTimeMilli); return true; } return false;