diff options
author | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-29 22:17:07 +0000 |
---|---|---|
committer | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-29 22:17:07 +0000 |
commit | f78e06b580ffa826b7c56a32f3df02dc6cde707f (patch) | |
tree | 549c47e7d15caf152a087558a9c790ba80922eb1 /chrome/browser | |
parent | 73b30c850eb92ecee33066ae755c4b2775f56800 (diff) | |
download | chromium_src-f78e06b580ffa826b7c56a32f3df02dc6cde707f.zip chromium_src-f78e06b580ffa826b7c56a32f3df02dc6cde707f.tar.gz chromium_src-f78e06b580ffa826b7c56a32f3df02dc6cde707f.tar.bz2 |
Significantly speed up loading net-internals log dumps.
I'm hoping this will also speed up a couple of the slower
tests, though I'm not sure it will.
I'm also hoping this will also speed up converting logs to
text, too, so when we implement full text search again, we
get better performance than before.
R=eroman@chromium.org
BUG=119731
Review URL: http://codereview.chromium.org/9910015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129705 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
5 files changed, 30 insertions, 11 deletions
diff --git a/chrome/browser/resources/net_internals/log_util.js b/chrome/browser/resources/net_internals/log_util.js index 78c7e34..9bbb052 100644 --- a/chrome/browser/resources/net_internals/log_util.js +++ b/chrome/browser/resources/net_internals/log_util.js @@ -176,10 +176,11 @@ log_util = (function() { var numDeprecatedPassiveEvents = 0; for (var eventIndex = 0; eventIndex < logDump.events.length; ++eventIndex) { var event = logDump.events[eventIndex]; - if (typeof(event) == 'object' && typeof(event.source) == 'object' && - typeof(event.time) == 'string' && - getKeyWithValue(LogEventType, event.type) != '?' && - getKeyWithValue(LogSourceType, event.source.type) != '?' && + if (typeof event == 'object' && + typeof event.source == 'object' && + typeof event.time == 'string' && + typeof LogEventTypeNames[event.type] == 'string' && + typeof LogSourceTypeNames[event.source.type] == 'string' && getKeyWithValue(LogEventPhase, event.phase) != '?') { if (event.wasPassivelyCaptured) { // NOTE: Up until Chrome 18, log dumps included "passively captured" diff --git a/chrome/browser/resources/net_internals/log_view_painter.js b/chrome/browser/resources/net_internals/log_view_painter.js index 9146903..876c6a0 100644 --- a/chrome/browser/resources/net_internals/log_view_painter.js +++ b/chrome/browser/resources/net_internals/log_view_painter.js @@ -206,7 +206,7 @@ function addRowsForExtraParams(tablePrinter, entry, enableSecurityStripping) { // string. if (k == 'source_dependency' && typeof value == 'object') { var link = '#events&s=' + value.id; - var sourceType = getKeyWithValue(LogSourceType, value.type); + var sourceType = LogSourceTypeNames[value.type]; paramStr += value.id + ' (' + sourceType + ')'; addTextRows(tablePrinter, paramStr, link); continue; @@ -402,7 +402,7 @@ function getTextForEvent(entry) { text = ' '; } - text += getKeyWithValue(LogEventType, entry.orig.type); + text += LogEventTypeNames[entry.orig.type]; return text; } diff --git a/chrome/browser/resources/net_internals/main.js b/chrome/browser/resources/net_internals/main.js index a5345eb..8f6d362 100644 --- a/chrome/browser/resources/net_internals/main.js +++ b/chrome/browser/resources/net_internals/main.js @@ -4,13 +4,16 @@ /** * Dictionary of constants (Initialized soon after loading by data from browser, - * updated on load log). + * updated on load log). The *Types dictionaries map strings to numeric IDs, + * while the *TypeNames are the other way around. */ var LogEventType = null; +var LogEventTypeNames = null; var LogEventPhase = null; -var ClientInfo = null; var LogSourceType = null; +var LogSourceTypeNames = null; var LogLevelType = null; +var ClientInfo = null; var NetError = null; var LoadFlag = null; var AddressFamily = null; @@ -241,10 +244,12 @@ ConstantsObserver.prototype.onReceivedConstants = function(receivedConstants) { Constants = receivedConstants; LogEventType = Constants.logEventTypes; - ClientInfo = Constants.clientInfo; + LogEventTypeNames = makeInverseMap(LogEventType); LogEventPhase = Constants.logEventPhase; LogSourceType = Constants.logSourceType; + LogSourceTypeNames = makeInverseMap(LogSourceType); LogLevelType = Constants.logLevelType; + ClientInfo = Constants.clientInfo; LoadFlag = Constants.loadFlag; NetError = Constants.netError; AddressFamily = Constants.addressFamily; diff --git a/chrome/browser/resources/net_internals/source_entry.js b/chrome/browser/resources/net_internals/source_entry.js index 4b1c7d8..fcca7ec 100644 --- a/chrome/browser/resources/net_internals/source_entry.js +++ b/chrome/browser/resources/net_internals/source_entry.js @@ -69,7 +69,7 @@ var SourceEntry = (function() { if (e.source.type == LogSourceType.NONE) { // NONE is what we use for global events that aren't actually grouped // by a "source ID", so we will just stringize the event's type. - this.description_ = getKeyWithValue(LogEventType, e.type); + this.description_ = LogEventTypeNames[e.type]; return; } @@ -235,7 +235,7 @@ var SourceEntry = (function() { }, getSourceTypeString: function() { - return getKeyWithValue(LogSourceType, this.entries_[0].source.type); + return LogSourceTypeNames[this.entries_[0].source.type]; }, getSourceType: function() { diff --git a/chrome/browser/resources/net_internals/util.js b/chrome/browser/resources/net_internals/util.js index fab6ad7..1864867 100644 --- a/chrome/browser/resources/net_internals/util.js +++ b/chrome/browser/resources/net_internals/util.js @@ -101,6 +101,19 @@ function getKeyWithValue(map, value) { } /** + * Returns a new map with the keys and values of the input map inverted. + * @param {!Object} map The object to have its keys and values reversed. Not + * modified by the function call. + * @return {Object} The new map with the reversed keys and values. + */ +function makeInverseMap(map) { + var reversed = {}; + for (var key in map) + reversed[map[key]] = key; + return reversed; +} + +/** * Looks up |key| in |map|, and returns the resulting entry, if there is one. * Otherwise, returns |key|. Intended primarily for use with incomplete * tables, and for reasonable behavior with system enumerations that may be |