diff options
author | mnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-02 11:45:24 +0000 |
---|---|---|
committer | mnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-02 11:45:24 +0000 |
commit | 4b9fa0c7b1844d11c5428d27f9ef68b5461222e4 (patch) | |
tree | 7db582f0ebb3d672d44e54208ae7ad0804d53ca4 /webkit | |
parent | 15d217c112791d7089857b3001d4ec6a1bcfeddc (diff) | |
download | chromium_src-4b9fa0c7b1844d11c5428d27f9ef68b5461222e4.zip chromium_src-4b9fa0c7b1844d11c5428d27f9ef68b5461222e4.tar.gz chromium_src-4b9fa0c7b1844d11c5428d27f9ef68b5461222e4.tar.bz2 |
DevTools Profiler UI changes.
- filter our V8 natives;
- display a notification that profile is being processed to avoid confusion;
- do not display ".000" part when displaying time.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/118112
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17399 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/devtools/js/debugger_agent.js | 16 | ||||
-rw-r--r-- | webkit/glue/devtools/js/devtools.js | 42 | ||||
-rw-r--r-- | webkit/glue/devtools/js/profiler_processor.js | 31 |
3 files changed, 76 insertions, 13 deletions
diff --git a/webkit/glue/devtools/js/debugger_agent.js b/webkit/glue/devtools/js/debugger_agent.js index e714326..3f7d14fb 100644 --- a/webkit/glue/devtools/js/debugger_agent.js +++ b/webkit/glue/devtools/js/debugger_agent.js @@ -611,6 +611,22 @@ devtools.DebuggerAgent.prototype.didIsProfilingStarted_ = function( if (is_started && !this.isProfilingStarted_) { // Start to query log data. RemoteDebuggerAgent.GetLogLines(this.lastProfileLogPosition_); + } else if (!is_started && this.isProfilingStarted_) { + // Display a temporary icon / message indicating that the profile + // is being processed. + var processingIcon = new WebInspector.SidebarTreeElement( + "profile-sidebar-tree-item", "Processing...", "", null, false); + var profilesSidebar = WebInspector.panels.profiles.sidebarTree; + profilesSidebar.appendChild(processingIcon); + var profilerProcessor = this.profilerProcessor_; + // Set a callback for adding a profile that removes the temporary element + // and restores plain "addProfile" callback. + profilerProcessor.setNewProfileCallback(function (profile) { + profilesSidebar.removeChild(processingIcon); + WebInspector.addProfile(profile); + profilerProcessor.setNewProfileCallback( + goog.bind(WebInspector.addProfile, WebInspector)); + }); } this.isProfilingStarted_ = is_started; // Update button. diff --git a/webkit/glue/devtools/js/devtools.js b/webkit/glue/devtools/js/devtools.js index c301e80..8287e63 100644 --- a/webkit/glue/devtools/js/devtools.js +++ b/webkit/glue/devtools/js/devtools.js @@ -3,7 +3,7 @@ // found in the LICENSE file. /** - * @fileoverview Tools is a main class that wires all components of the + * @fileoverview Tools is a main class that wires all components of the * DevTools frontend together. It is also responsible for overriding existing * WebInspector functionality while it is getting upstreamed into WebCore. */ @@ -60,7 +60,7 @@ devtools.ToolsAgent = function() { devtools.ToolsAgent.prototype.reset = function() { this.domAgent_.reset(); this.debuggerAgent_.reset(); - + this.domAgent_.getDocumentElementAsync(); }; @@ -154,10 +154,10 @@ devtools.ToolsAgent.prototype.evaluate = function(expr) { /** * Asynchronously queries for the resource content. * @param {number} identifier Resource identifier. - * @param {function(string):undefined} opt_callback Callback to call when + * @param {function(string):undefined} opt_callback Callback to call when * result is available. */ -devtools.ToolsAgent.prototype.getResourceContentAsync = function(identifier, +devtools.ToolsAgent.prototype.getResourceContentAsync = function(identifier, opt_callback) { var resource = WebInspector.resources[identifier]; if (!resource) { @@ -241,12 +241,12 @@ WebInspector.ElementsPanel.prototype.performSearchCallback_ = function(nodes) { if (treeElement) treeElement.highlighted = true; } - + if (nodes.length) { this.currentSearchResultIndex_ = 0; this.focusedDOMNode = nodes[0]; } - + this.searchResultCount_ = nodes.length; }; @@ -361,7 +361,7 @@ WebInspector.ElementsPanel.prototype.invokeWithStyleSet_ = var node = this.focusedDOMNode; if (node && node.nodeType === Node.TEXT_NODE && node.parentNode) node = node.parentNode; - + if (node && node.nodeType == Node.ELEMENT_NODE) { var callback = function(stylesStr) { var styles = JSON.parse(stylesStr); @@ -425,9 +425,9 @@ WebInspector.PropertiesSidebarPane.prototype.update = function(object) { return; } - + var self = this; - devtools.tools.getDomAgent().getNodePrototypesAsync(object.id_, + devtools.tools.getDomAgent().getNodePrototypesAsync(object.id_, function(json) { // Get array of prototype user-friendly names. var prototypes = JSON.parse(json); @@ -497,7 +497,7 @@ WebInspector.SidebarObjectPropertyTreeElement.prototype.onpopulate = var nodeId = this.parentObject.devtools$$nodeId_; var path = this.parentObject.devtools$$path_.slice(0); path.push(this.propertyName); - devtools.tools.getDomAgent().getNodePropertiesAsync(nodeId, path, -1, + devtools.tools.getDomAgent().getNodePropertiesAsync(nodeId, path, -1, goog.partial( WebInspector.didGetNodePropertiesAsync_, this, @@ -550,7 +550,7 @@ WebInspector.ScriptView.prototype.setupSourceFrameIfNeeded = function() { } this.attach(); - + if (this.script.source) { this.didResolveScriptSource_(); } else { @@ -921,6 +921,26 @@ WebInspector.ProfileDataGridNode.prototype._populate = function(event) { })(); +// WebKit's profiler displays milliseconds with high resolution (shows +// three digits after the decimal point). We never have such resolution, +// as our minimal sampling rate is 1 ms. So we are disabling high resolution +// to avoid visual clutter caused by meaningless ".000" parts. +(function InterceptTimeDisplayInProfiler() { + var originalDataGetter = + WebInspector.ProfileDataGridNode.prototype.__lookupGetter__('data'); + WebInspector.ProfileDataGridNode.prototype.__defineGetter__('data', + function() { + var oldNumberSecondsToString = Number.secondsToString; + Number.secondsToString = function(seconds, formatterFunction) { + return oldNumberSecondsToString(seconds, formatterFunction, false); + }; + var data = originalDataGetter.call(this); + Number.secondsToString = oldNumberSecondsToString; + return data; + }); +})(); + + /** * @override * TODO(pfeldman): Add l10n. diff --git a/webkit/glue/devtools/js/profiler_processor.js b/webkit/glue/devtools/js/profiler_processor.js index 3f13129..4c4e7ef 100644 --- a/webkit/glue/devtools/js/profiler_processor.js +++ b/webkit/glue/devtools/js/profiler_processor.js @@ -21,16 +21,32 @@ goog.inherits(devtools.profiler.JsProfile, devtools.profiler.Profile); /** + * RegExp that leaves only JS functions. * @type {RegExp} */ devtools.profiler.JsProfile.JS_FUNC_RE = /^(LazyCompile|Function|Script):/; +/** + * RegExp that filters out native code (ending with "native src.js:xxx"). + * @type {RegExp} + */ +devtools.profiler.JsProfile.JS_NATIVE_FUNC_RE = /\ native\ \w+\.js:\d+$/; + +/** + * RegExp that filters out native scripts. + * @type {RegExp} + */ +devtools.profiler.JsProfile.JS_NATIVE_SCRIPT_RE = /^Script:\ native/; + /** * @override */ devtools.profiler.JsProfile.prototype.skipThisFunction = function(name) { - return !devtools.profiler.JsProfile.JS_FUNC_RE.test(name); + return !devtools.profiler.JsProfile.JS_FUNC_RE.test(name) || + // To profile V8's natives comment out two lines below and '||' above. + devtools.profiler.JsProfile.JS_NATIVE_FUNC_RE.test(name) || + devtools.profiler.JsProfile.JS_NATIVE_SCRIPT_RE.test(name); }; @@ -43,7 +59,8 @@ devtools.profiler.JsProfile.prototype.skipThisFunction = function(name) { */ devtools.profiler.Processor = function(newProfileCallback) { /** - * + * Callback that adds a new profile to view. + * @type {function(devtools.profiler.ProfileView)} */ this.newProfileCallback_ = newProfileCallback; @@ -98,6 +115,16 @@ devtools.profiler.Processor.RecordsDispatch_ = { /** + * Sets new profile callback. + * @param {function(devtools.profiler.ProfileView)} callback Callback function. + */ +devtools.profiler.Processor.prototype.setNewProfileCallback = function( + callback) { + this.newProfileCallback_ = callback; +}; + + +/** * Processes a portion of V8 profiler event log. * * @param {string} chunk A portion of log. |