Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview Profiler processor is used to process log file produced | 6 * @fileoverview Profiler processor is used to process log file produced |
| 7 * by V8 and produce an internal profile representation which is used | 7 * by V8 and produce an internal profile representation which is used |
| 8 * for building profile views in 'Profiles' tab. | 8 * for building profile views in 'Profiles' tab. |
| 9 */ | 9 */ |
| 10 goog.provide('devtools.profiler.Processor'); | 10 goog.provide('devtools.profiler.Processor'); |
| 11 | 11 |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Ancestor of a profile object that leaves out only JS-related functions. | 14 * Ancestor of a profile object that leaves out only JS-related functions. |
| 15 * @constructor | 15 * @constructor |
| 16 */ | 16 */ |
| 17 devtools.profiler.JsProfile = function() { | 17 devtools.profiler.JsProfile = function() { |
| 18 devtools.profiler.Profile.call(this); | 18 devtools.profiler.Profile.call(this); |
| 19 }; | 19 }; |
| 20 goog.inherits(devtools.profiler.JsProfile, devtools.profiler.Profile); | 20 goog.inherits(devtools.profiler.JsProfile, devtools.profiler.Profile); |
| 21 | 21 |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * RegExp that leaves only JS functions. | |
| 24 * @type {RegExp} | 25 * @type {RegExp} |
| 25 */ | 26 */ |
| 26 devtools.profiler.JsProfile.JS_FUNC_RE = /^(LazyCompile|Function|Script):/; | 27 devtools.profiler.JsProfile.JS_FUNC_RE = /^(LazyCompile|Function|Script):/; |
| 27 | 28 |
| 29 /** | |
| 30 * RegExp that filters out native code (ending with "native src.js:xxx"). | |
| 31 * @type {RegExp} | |
| 32 */ | |
| 33 devtools.profiler.JsProfile.JS_NATIVE_FUNC_RE = /\ native\ \w+\.js:\d+$/; | |
| 34 | |
| 35 /** | |
| 36 * RegExp that filters out native scripts. | |
| 37 * @type {RegExp} | |
| 38 */ | |
| 39 devtools.profiler.JsProfile.JS_NATIVE_SCRIPT_RE = /^Script:\ native/; | |
| 40 | |
| 28 | 41 |
| 29 /** | 42 /** |
| 30 * @override | 43 * @override |
| 31 */ | 44 */ |
| 32 devtools.profiler.JsProfile.prototype.skipThisFunction = function(name) { | 45 devtools.profiler.JsProfile.prototype.skipThisFunction = function(name) { |
| 33 return !devtools.profiler.JsProfile.JS_FUNC_RE.test(name); | 46 return !devtools.profiler.JsProfile.JS_FUNC_RE.test(name) || |
| 47 devtools.profiler.JsProfile.JS_NATIVE_FUNC_RE.test(name) || | |
|
pfeldman
2009/06/02 11:30:24
Could you hide this behind the flag / option at le
mnaganov (inactive)
2009/06/02 11:44:43
Added a comment that you need to comment out these
| |
| 48 devtools.profiler.JsProfile.JS_NATIVE_SCRIPT_RE.test(name); | |
| 34 }; | 49 }; |
| 35 | 50 |
| 36 | 51 |
| 37 /** | 52 /** |
| 38 * Profiler processor. Consumes profiler log and builds profile views. | 53 * Profiler processor. Consumes profiler log and builds profile views. |
| 39 * | 54 * |
| 40 * @param {function(devtools.profiler.ProfileView)} newProfileCallback Callback | 55 * @param {function(devtools.profiler.ProfileView)} newProfileCallback Callback |
| 41 * that receives a new processed profile. | 56 * that receives a new processed profile. |
| 42 * @constructor | 57 * @constructor |
| 43 */ | 58 */ |
| 44 devtools.profiler.Processor = function(newProfileCallback) { | 59 devtools.profiler.Processor = function(newProfileCallback) { |
| 45 /** | 60 /** |
| 46 * | 61 * Callback that adds a new profile to view. |
| 62 * @type {function(devtools.profiler.ProfileView)} | |
| 47 */ | 63 */ |
| 48 this.newProfileCallback_ = newProfileCallback; | 64 this.newProfileCallback_ = newProfileCallback; |
| 49 | 65 |
| 50 /** | 66 /** |
| 51 * Profiles array. | 67 * Profiles array. |
| 52 * @type {Array<devtools.profiler.JsProfile>} | 68 * @type {Array<devtools.profiler.JsProfile>} |
| 53 */ | 69 */ |
| 54 this.profiles_ = []; | 70 this.profiles_ = []; |
| 55 | 71 |
| 56 /** | 72 /** |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 // Not used in DevTools Profiler. | 107 // Not used in DevTools Profiler. |
| 92 'shared-library': null, | 108 'shared-library': null, |
| 93 // Obsolete row types. | 109 // Obsolete row types. |
| 94 'code-allocate': null, | 110 'code-allocate': null, |
| 95 'begin-code-region': null, | 111 'begin-code-region': null, |
| 96 'end-code-region': null | 112 'end-code-region': null |
| 97 }; | 113 }; |
| 98 | 114 |
| 99 | 115 |
| 100 /** | 116 /** |
| 117 * Sets new profile callback. | |
| 118 * @param {function(devtools.profiler.ProfileView)} callback Callback function. | |
| 119 */ | |
| 120 devtools.profiler.Processor.prototype.setNewProfileCallback = function( | |
| 121 callback) { | |
| 122 this.newProfileCallback_ = callback; | |
| 123 }; | |
| 124 | |
| 125 | |
| 126 /** | |
| 101 * Processes a portion of V8 profiler event log. | 127 * Processes a portion of V8 profiler event log. |
| 102 * | 128 * |
| 103 * @param {string} chunk A portion of log. | 129 * @param {string} chunk A portion of log. |
| 104 */ | 130 */ |
| 105 devtools.profiler.Processor.prototype.processLogChunk = function(chunk) { | 131 devtools.profiler.Processor.prototype.processLogChunk = function(chunk) { |
| 106 this.processLog_(chunk.split('\n')); | 132 this.processLog_(chunk.split('\n')); |
| 107 }; | 133 }; |
| 108 | 134 |
| 109 | 135 |
| 110 /** | 136 /** |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 profile.title = UserInitiatedProfileName + '.' + profile.uid; | 256 profile.title = UserInitiatedProfileName + '.' + profile.uid; |
| 231 // A trick to cope with ProfileView.bottomUpProfileDataGridTree and | 257 // A trick to cope with ProfileView.bottomUpProfileDataGridTree and |
| 232 // ProfileView.topDownProfileDataGridTree behavior. | 258 // ProfileView.topDownProfileDataGridTree behavior. |
| 233 profile.head = profile; | 259 profile.head = profile; |
| 234 profile.heavyProfile = this.viewBuilder_.buildView( | 260 profile.heavyProfile = this.viewBuilder_.buildView( |
| 235 this.currentProfile_.getBottomUpProfile(), true); | 261 this.currentProfile_.getBottomUpProfile(), true); |
| 236 profile.treeProfile = this.viewBuilder_.buildView( | 262 profile.treeProfile = this.viewBuilder_.buildView( |
| 237 this.currentProfile_.getTopDownProfile()); | 263 this.currentProfile_.getTopDownProfile()); |
| 238 return profile; | 264 return profile; |
| 239 }; | 265 }; |
| OLD | NEW |