summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nandana Dutt <nandana@google.com> 2019-03-14 11:04:22 +0000
committer Nandana Dutt <nandana@google.com> 2019-03-14 11:04:22 +0000
commitb86f33be6ace62c9c8185f1d5e7d531909c8d6b0 (patch)
treef0912cb5aebdcb04d6ad569bd794315ff69b8efb
parentb0f2b48c0a2cecbcf971a526025ca763950b3ef1 (diff)
dumpstate: Log duration only if significant
Ignore durations shorter than 500ms. Also adjust the precision of the duration logged accordingly. This is to avoid log spam. Test: verified logcat on bugreport Change-Id: Ibcef6b107de4327f769242c0c43d7f5317eee7f6
-rw-r--r--cmds/dumpstate/utils.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp
index 8b9298820d..4efa99b59b 100644
--- a/cmds/dumpstate/utils.cpp
+++ b/cmds/dumpstate/utils.cpp
@@ -102,14 +102,16 @@ DurationReporter::DurationReporter(const std::string& title, bool logcat_only)
DurationReporter::~DurationReporter() {
if (!title_.empty()) {
- uint64_t elapsed = Nanotime() - started_;
- MYLOGD("Duration of '%s': %.3fs\n", title_.c_str(), (float)elapsed / NANOS_PER_SEC);
+ float elapsed = (float)(Nanotime() - started_) / NANOS_PER_SEC;
+ if (elapsed < .5f) {
+ return;
+ }
+ MYLOGD("Duration of '%s': %.2fs\n", title_.c_str(), elapsed);
if (logcat_only_) {
return;
}
// Use "Yoda grammar" to make it easier to grep|sort sections.
- printf("------ %.3fs was the duration of '%s' ------\n", (float)elapsed / NANOS_PER_SEC,
- title_.c_str());
+ printf("------ %.3fs was the duration of '%s' ------\n", elapsed, title_.c_str());
}
}