diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-13 01:21:17 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-13 01:21:17 +0000 |
commit | a89ada7b8f9c097de22449139a2eb5023571aaaa (patch) | |
tree | 938ee2c3d26ecd34e1924f55998170bafa891509 /net | |
parent | 6fdf27572a1683448fc8c22f47c3f11391e580ef (diff) | |
download | chromium_src-a89ada7b8f9c097de22449139a2eb5023571aaaa.zip chromium_src-a89ada7b8f9c097de22449139a2eb5023571aaaa.tar.gz chromium_src-a89ada7b8f9c097de22449139a2eb5023571aaaa.tar.bz2 |
Condense the output of LoadLog for empty BEGIN/END blocks.
Rather then printing across two lines, just do it on one line.
Review URL: http://codereview.chromium.org/387043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31870 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/load_log_util.cc | 26 | ||||
-rw-r--r-- | net/base/load_log_util_unittest.cc | 3 |
2 files changed, 23 insertions, 6 deletions
diff --git a/net/base/load_log_util.cc b/net/base/load_log_util.cc index c9de440f..df31218 100644 --- a/net/base/load_log_util.cc +++ b/net/base/load_log_util.cc @@ -30,14 +30,19 @@ class FormatHelper { const int kSpacesPerIndentation = 2; for (size_t i = 0; i < entries_.size(); ++i) { - if (i > 0) - result += "\n"; - if (log->num_entries_truncated() > 0 && i + 1 == entries_.size()) { result += StringPrintf(" ... Truncated %d entries ...\n", log->num_entries_truncated()); } + if (entries_[i].block_index != -1 && + static_cast<size_t>(entries_[i].block_index + 1) == i) { + // If there were no entries in between the START/END block then don't + // bother printing a line for END (it just adds noise, and we already + // show the time delta besides START anyway). + continue; + } + int indentation_spaces = entries_[i].indentation * kSpacesPerIndentation; std::string event_str = GetEventString(i); @@ -54,6 +59,9 @@ class FormatHelper { PadStringLeft("", padding).c_str(), PadStringLeft(GetBlockDtString(i), max_dt_width).c_str()); } + + if (i + 1 != entries_.size()) + result += "\n"; } return result; @@ -150,7 +158,17 @@ class FormatHelper { const LoadLog::Event* event = entries_[index].event; const char* type_str = LoadLog::EventTypeToString(event->type); - switch (event->phase) { + LoadLog::EventPhase phase = event->phase; + + if (phase == LoadLog::PHASE_BEGIN && + index + 1 < entries_.size() && + static_cast<size_t>(entries_[index + 1].block_index) == index) { + // If this starts an empty block, we will pretend it is a PHASE_NONE + // so we don't print the "+" prefix. + phase = LoadLog::PHASE_NONE; + } + + switch (phase) { case LoadLog::PHASE_BEGIN: return std::string("+") + type_str; case LoadLog::PHASE_END: diff --git a/net/base/load_log_util_unittest.cc b/net/base/load_log_util_unittest.cc index 4766a86f..4ca3854 100644 --- a/net/base/load_log_util_unittest.cc +++ b/net/base/load_log_util_unittest.cc @@ -22,8 +22,7 @@ TEST(LoadLogUtilTest, Basic) { EXPECT_EQ( "t= 1: +HOST_RESOLVER_IMPL [dt=130]\n" - "t= 5: +HOST_RESOLVER_IMPL_OBSERVER_ONSTART [dt= 3]\n" - "t= 8: -HOST_RESOLVER_IMPL_OBSERVER_ONSTART\n" + "t= 5: HOST_RESOLVER_IMPL_OBSERVER_ONSTART [dt= 3]\n" "t= 12: CANCELLED\n" "t=131: -HOST_RESOLVER_IMPL", LoadLogUtil::PrettyPrintAsEventTree(log)); |