From 6b5c5aa0679139aac403e4b6a1778c27e100a48e Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Thu, 16 Feb 2017 11:53:03 -0800 Subject: [PATCH] bootstat: Report the total bootloader time. Bug: 35207415 Test: none Change-Id: Id948a3b35bb3d96dc875d0a4eea869c86a71a657 --- bootstat/bootstat.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bootstat/bootstat.cpp b/bootstat/bootstat.cpp index a7354a7d3..a4cc5f22e 100644 --- a/bootstat/bootstat.cpp +++ b/bootstat/bootstat.cpp @@ -225,7 +225,12 @@ void RecordInitBootTimeProp( void RecordBootloaderTimings(BootEventRecordStore* boot_event_store) { // |ro.boot.boottime| is of the form 'stage1:time1,...,stageN:timeN'. std::string value = GetProperty("ro.boot.boottime"); + if (value.empty()) { + // ro.boot.boottime is not reported on all devices. + return; + } + int32_t total_time = 0; auto stages = android::base::Split(value, ","); for (auto const &stageTiming : stages) { // |stageTiming| is of the form 'stage:time'. @@ -235,10 +240,13 @@ void RecordBootloaderTimings(BootEventRecordStore* boot_event_store) { std::string stageName = stageTimingValues[0]; int32_t time_ms; if (android::base::ParseInt(stageTimingValues[1], &time_ms)) { + total_time += time_ms; boot_event_store->AddBootEventWithValue( "boottime.bootloader." + stageName, time_ms); } } + + boot_event_store->AddBootEventWithValue("boottime.bootloader.total", total_time); } // Records several metrics related to the time it takes to boot the device,