summaryrefslogtreecommitdiffstats
path: root/net/base/load_log_util.h
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-14 03:01:09 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-14 03:01:09 +0000
commit54e1377ea309c5d8ab318ee9691b46249d7441b6 (patch)
tree8471e44056027dff255ff5b22ba083a9482b41c3 /net/base/load_log_util.h
parent672eca0fd191acd39c28430d1ed1f327594faff8 (diff)
downloadchromium_src-54e1377ea309c5d8ab318ee9691b46249d7441b6.zip
chromium_src-54e1377ea309c5d8ab318ee9691b46249d7441b6.tar.gz
chromium_src-54e1377ea309c5d8ab318ee9691b46249d7441b6.tar.bz2
Implement LoadLog, and hook up HostResolverImpl to LoadLog.
The functionality in load_log_util.h is currently unused, but since it motivates the implementation of LoadLog, figured it should be included with this review. Note that I decided against defining the loggable event types as LoadStates, since I wanted more flexibility in adding crazy stuff, and they really seem too implementation specific to be in LoadStates. BUG=http://crbug.com/14478 TEST=net_unittests Review URL: http://codereview.chromium.org/165404 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23412 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/load_log_util.h')
-rw-r--r--net/base/load_log_util.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/net/base/load_log_util.h b/net/base/load_log_util.h
new file mode 100644
index 0000000..363e219
--- /dev/null
+++ b/net/base/load_log_util.h
@@ -0,0 +1,74 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_BASE_LOAD_LOG_UTIL_H_
+#define NET_BASE_LOAD_LOG_UTIL_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "net/base/load_log.h"
+
+namespace net {
+
+// The LoadLogUtil utility class contains methods to analyze and visualize
+// LoadLogs.
+
+class LoadLogUtil {
+ public:
+ struct EventDuration {
+ LoadLog::EventType event;
+ base::TimeDelta duration;
+ };
+ typedef std::vector<EventDuration> EventDurationList;
+
+ // Builds a pretty printed ASCII tree showing the chronological order
+ // of events.
+ //
+ // The indentation reflects hiearchy, with the duration of each indented
+ // block noted on the right. The timestamp (tick count in milliseconds)
+ // is noted in the left column.
+ //
+ // This detailed view of what went into servicing a request can be used
+ // in logs, and is copy-pastable by users, for attaching to bug reports.
+ //
+ // Example A:
+ //
+ // t=0: +Event1 [dt = 8]
+ // t=1: +Event2 [dt = 0]
+ // t=1: EventX
+ // t=1: -Event2
+ // t=4: +Event3 [dt = 2]
+ // t=6: -Event3
+ // t=6: +Event2 [dt = 1]
+ // t=7: -Event2
+ // t=8: EventY
+ // t=8: -Event1
+ //
+ // Here we can see that:
+ // - Event1 started at t=0 and ended at t=8; the duration was 8 time units.
+ // - Event2 took place while Event1 was in progress, and was repeated
+ // at t=1 and t=6.
+ // - EventX took place while (the first) Event2 was in progress.
+ // - Event3 started and ended at the same time, taking 0 time.
+ // - EventY took place right before Event1 finished, at t=8
+ //
+ // In general the rules are:
+ // - Log entries added by BeginEvent() are prefixed with a '+' and
+ // start an indentation block.
+ // - Log entries added by EndEvent() are prefixed with a '-' and
+ // finish an indentation block.
+ // - Log entries added by AddEvent() have no prefix.
+ // - Time units are given as milliseconds.
+ //
+ static std::string PrettyPrintAsEventTree(const LoadLog* log);
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(LoadLogUtil);
+};
+
+} // namespace net
+
+#endif // NET_BASE_LOAD_LOG_UTIL_H_