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/server/main.cpp b/server/main.cpp
index b783ce5..c697c3d 100644
--- a/server/main.cpp
+++ b/server/main.cpp
@@ -14,19 +14,19 @@
* limitations under the License.
*/
-#include <chrono>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
-#include <signal.h>
-#include <errno.h>
#include <string.h>
-#include <mutex>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
-
-#include <fcntl.h>
-#include <dirent.h>
+#include <chrono>
+#include <cinttypes>
+#include <mutex>
#define LOG_TAG "Netd"
@@ -175,7 +175,7 @@
ALOGE("Unable to start NetdNativeService: %d", ret);
exit(1);
}
- gLog.info("Registering NetdNativeService: %.1fms", subTime.getTimeAndReset());
+ gLog.info("Registering NetdNativeService: %" PRId64 "us", subTime.getTimeAndResetUs());
android::net::process::ScopedPidFile pidFile(PID_FILE_PATH);
@@ -186,9 +186,8 @@
ALOGE("Unable to start NetdHwService: %d", ret);
exit(1);
}
- gLog.info("Registering NetdHwService: %.1fms", subTime.getTimeAndReset());
-
- gLog.info("Netd started in %dms", static_cast<int>(s.timeTaken()));
+ gLog.info("Registering NetdHwService: %" PRId64 "us", subTime.getTimeAndResetUs());
+ gLog.info("Netd started in %" PRId64 "us", s.timeTakenUs());
IPCThreadState::self()->joinThreadPool();