Merge "boottime/init: Report ro.boottime.init* properties in milliseconds."

This commit is contained in:
James Hawkins 2017-01-27 18:37:21 +00:00 committed by Gerrit Code Review
commit 7dde4fa4e2
4 changed files with 10 additions and 11 deletions

View File

@ -212,10 +212,8 @@ void RecordInitBootTimeProp(
BootEventRecordStore* boot_event_store, const char* property) {
std::string value = GetProperty(property);
int32_t time_in_ns;
if (android::base::ParseInt(value, &time_in_ns)) {
static constexpr int32_t kNanosecondsPerMillisecond = 1e6;
int32_t time_in_ms = static_cast<int32_t>(time_in_ns / kNanosecondsPerMillisecond);
int32_t time_in_ms;
if (android::base::ParseInt(value, &time_in_ms)) {
boot_event_store->AddBootEventWithValue(property, time_in_ms);
}
}

View File

@ -178,7 +178,7 @@ static int wait_for_coldboot_done_action(const std::vector<std::string>& args) {
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 @@ static void selinux_initialize(bool in_kernel_domain) {
}
// 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 @@ int main(int argc, char** argv) {
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 };

View File

@ -276,7 +276,7 @@ class SocketConnection {
while (*timeout_ms > 0) {
Timer timer;
int nr = poll(ufds, 1, *timeout_ms);
uint64_t millis = timer.duration_ns()/1000000;
uint64_t millis = timer.duration_ms();
*timeout_ms = (millis > *timeout_ms) ? 0 : *timeout_ms - millis;
if (nr > 0) {

View File

@ -55,8 +55,8 @@ class Timer {
return std::chrono::duration_cast<double_duration>(boot_clock::now() - start_).count();
}
int64_t duration_ns() const {
return (boot_clock::now() - start_).count();
int64_t duration_ms() const {
return std::chrono::duration_cast<std::chrono::milliseconds>(boot_clock::now() - start_).count();
}
private: