Remove floating-point time functions from StopWatch
Converting time units between floating-point milliseconds to integral
micros and floating-point seconds is error prone and leads to subtle
rounding bugs. Thus, consolidate all callers on microseconds and delete
the older methods.
Test: cd system/netd && atest .
Change-Id: Ief6ad4dbd21f442bfd65e78d49548677f3172a53
diff --git a/tests/benchmarks/connect_benchmark.cpp b/tests/benchmarks/connect_benchmark.cpp
index e08fb01..ed90538 100644
--- a/tests/benchmarks/connect_benchmark.cpp
+++ b/tests/benchmarks/connect_benchmark.cpp
@@ -125,8 +125,8 @@
}
if (waitBetweenRuns) {
- latencies[iterations] = stopwatch.timeTaken() * 1e6L;
- state.SetIterationTime(latencies[iterations] / 1e9L);
+ latencies[iterations] = stopwatch.timeTakenUs();
+ state.SetIterationTime(static_cast<double>(latencies[iterations]) / 1.0e6L);
std::this_thread::sleep_for(std::chrono::milliseconds(10));
++iterations;
}
@@ -182,8 +182,8 @@
}
if (waitBetweenRuns) {
- latencies[iterations] = stopwatch.timeTaken() * 1e6L;
- state.SetIterationTime(latencies[iterations] / 1e9L);
+ latencies[iterations] = stopwatch.timeTakenUs();
+ state.SetIterationTime(static_cast<double>(latencies[iterations]) / 1.0e6L);
std::this_thread::sleep_for(std::chrono::milliseconds(10));
++iterations;
}