boottime/init: Report ro.boottime.init* properties in milliseconds.
* Nanosecond precision ended up being harder to grok.
* This change modifies the Timer class to have duration_ms instead of
duration_ns.
Bug: 34466121
Test: adb logcat | grep bootstat
Change-Id: Ibd1c27dc3cb29d838a956e342281b2fb98d752a6
diff --git a/init/init.cpp b/init/init.cpp
index 1ce3c35..e7772e7 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -178,7 +178,7 @@
panic();
}
- property_set("ro.boottime.init.cold_boot_wait", std::to_string(t.duration_ns()).c_str());
+ property_set("ro.boottime.init.cold_boot_wait", std::to_string(t.duration_ms()).c_str());
return 0;
}
@@ -576,7 +576,7 @@
}
// init's first stage can't set properties, so pass the time to the second stage.
- setenv("INIT_SELINUX_TOOK", std::to_string(t.duration_ns()).c_str(), 1);
+ setenv("INIT_SELINUX_TOOK", std::to_string(t.duration_ms()).c_str(), 1);
} else {
selinux_init_all_handles();
}
@@ -757,8 +757,9 @@
setenv("INIT_SECOND_STAGE", "true", 1);
- uint64_t start_ns = start_time.time_since_epoch().count();
- setenv("INIT_STARTED_AT", StringPrintf("%" PRIu64, start_ns).c_str(), 1);
+ static constexpr uint32_t kNanosecondsPerMillisecond = 1e6;
+ uint64_t start_ms = start_time.time_since_epoch().count() / kNanosecondsPerMillisecond;
+ setenv("INIT_STARTED_AT", StringPrintf("%" PRIu64, start_ms).c_str(), 1);
char* path = argv[0];
char* args[] = { path, nullptr };