OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * @constructor | 6 * @constructor |
7 */ | 7 */ |
8 WebInspector.LineLevelProfile = function() | 8 WebInspector.LineLevelProfile = function() |
9 { | 9 { |
10 this._locationPool = new WebInspector.LiveLocationPool(); | 10 this._locationPool = new WebInspector.LiveLocationPool(); |
11 this.reset(); | 11 this.reset(); |
12 } | 12 }; |
13 | 13 |
14 /** | 14 /** |
15 * @return {!WebInspector.LineLevelProfile} | 15 * @return {!WebInspector.LineLevelProfile} |
16 */ | 16 */ |
17 WebInspector.LineLevelProfile.instance = function() | 17 WebInspector.LineLevelProfile.instance = function() |
18 { | 18 { |
19 if (!WebInspector.LineLevelProfile._instance) | 19 if (!WebInspector.LineLevelProfile._instance) |
20 WebInspector.LineLevelProfile._instance = new WebInspector.LineLevelProf
ile(); | 20 WebInspector.LineLevelProfile._instance = new WebInspector.LineLevelProf
ile(); |
21 return WebInspector.LineLevelProfile._instance; | 21 return WebInspector.LineLevelProfile._instance; |
22 } | 22 }; |
23 | 23 |
24 WebInspector.LineLevelProfile.prototype = { | 24 WebInspector.LineLevelProfile.prototype = { |
25 /** | 25 /** |
26 * @param {!WebInspector.CPUProfileDataModel} profile | 26 * @param {!WebInspector.CPUProfileDataModel} profile |
27 */ | 27 */ |
28 appendCPUProfile: function(profile) | 28 appendCPUProfile: function(profile) |
29 { | 29 { |
30 var nodesToGo = [profile.profileHead]; | 30 var nodesToGo = [profile.profileHead]; |
31 var sampleDuration = (profile.profileEndTime - profile.profileStartTime)
/ profile.totalHitCount; | 31 var sampleDuration = (profile.profileEndTime - profile.profileStartTime)
/ profile.totalHitCount; |
32 while (nodesToGo.length) { | 32 while (nodesToGo.length) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 var line = lineInfo[0] - 1; | 87 var line = lineInfo[0] - 1; |
88 var time = lineInfo[1]; | 88 var time = lineInfo[1]; |
89 var rawLocation = debuggerModel.createRawLocationByURL(url, line
, 0); | 89 var rawLocation = debuggerModel.createRawLocationByURL(url, line
, 0); |
90 if (rawLocation) | 90 if (rawLocation) |
91 new WebInspector.LineLevelProfile.Presentation(rawLocation,
time, this._locationPool); | 91 new WebInspector.LineLevelProfile.Presentation(rawLocation,
time, this._locationPool); |
92 else if (uiSourceCode) | 92 else if (uiSourceCode) |
93 uiSourceCode.addLineDecoration(line, WebInspector.LineLevelP
rofile.LineDecorator.type, time); | 93 uiSourceCode.addLineDecoration(line, WebInspector.LineLevelP
rofile.LineDecorator.type, time); |
94 } | 94 } |
95 } | 95 } |
96 } | 96 } |
97 } | 97 }; |
98 | 98 |
99 /** | 99 /** |
100 * @constructor | 100 * @constructor |
101 * @param {!WebInspector.DebuggerModel.Location} rawLocation | 101 * @param {!WebInspector.DebuggerModel.Location} rawLocation |
102 * @param {number} time | 102 * @param {number} time |
103 * @param {!WebInspector.LiveLocationPool} locationPool | 103 * @param {!WebInspector.LiveLocationPool} locationPool |
104 */ | 104 */ |
105 WebInspector.LineLevelProfile.Presentation = function(rawLocation, time, locatio
nPool) | 105 WebInspector.LineLevelProfile.Presentation = function(rawLocation, time, locatio
nPool) |
106 { | 106 { |
107 this._time = time; | 107 this._time = time; |
108 WebInspector.debuggerWorkspaceBinding.createLiveLocation(rawLocation, this.u
pdateLocation.bind(this), locationPool); | 108 WebInspector.debuggerWorkspaceBinding.createLiveLocation(rawLocation, this.u
pdateLocation.bind(this), locationPool); |
109 } | 109 }; |
110 | 110 |
111 WebInspector.LineLevelProfile.Presentation.prototype = { | 111 WebInspector.LineLevelProfile.Presentation.prototype = { |
112 /** | 112 /** |
113 * @param {!WebInspector.LiveLocation} liveLocation | 113 * @param {!WebInspector.LiveLocation} liveLocation |
114 */ | 114 */ |
115 updateLocation: function(liveLocation) | 115 updateLocation: function(liveLocation) |
116 { | 116 { |
117 if (this._uiLocation) | 117 if (this._uiLocation) |
118 this._uiLocation.uiSourceCode.removeLineDecoration(this._uiLocation.
lineNumber, WebInspector.LineLevelProfile.LineDecorator.type); | 118 this._uiLocation.uiSourceCode.removeLineDecoration(this._uiLocation.
lineNumber, WebInspector.LineLevelProfile.LineDecorator.type); |
119 this._uiLocation = liveLocation.uiLocation(); | 119 this._uiLocation = liveLocation.uiLocation(); |
120 if (this._uiLocation) | 120 if (this._uiLocation) |
121 this._uiLocation.uiSourceCode.addLineDecoration(this._uiLocation.lin
eNumber, WebInspector.LineLevelProfile.LineDecorator.type, this._time); | 121 this._uiLocation.uiSourceCode.addLineDecoration(this._uiLocation.lin
eNumber, WebInspector.LineLevelProfile.LineDecorator.type, this._time); |
122 } | 122 } |
123 } | 123 }; |
124 | 124 |
125 /** | 125 /** |
126 * @constructor | 126 * @constructor |
127 * @implements {WebInspector.UISourceCodeFrame.LineDecorator} | 127 * @implements {WebInspector.UISourceCodeFrame.LineDecorator} |
128 */ | 128 */ |
129 WebInspector.LineLevelProfile.LineDecorator = function() | 129 WebInspector.LineLevelProfile.LineDecorator = function() |
130 { | 130 { |
131 } | 131 }; |
132 | 132 |
133 WebInspector.LineLevelProfile.LineDecorator.type = "performance"; | 133 WebInspector.LineLevelProfile.LineDecorator.type = "performance"; |
134 | 134 |
135 WebInspector.LineLevelProfile.LineDecorator.prototype = { | 135 WebInspector.LineLevelProfile.LineDecorator.prototype = { |
136 /** | 136 /** |
137 * @override | 137 * @override |
138 * @param {!WebInspector.UISourceCode} uiSourceCode | 138 * @param {!WebInspector.UISourceCode} uiSourceCode |
139 * @param {!WebInspector.CodeMirrorTextEditor} textEditor | 139 * @param {!WebInspector.CodeMirrorTextEditor} textEditor |
140 */ | 140 */ |
141 decorate: function(uiSourceCode, textEditor) | 141 decorate: function(uiSourceCode, textEditor) |
142 { | 142 { |
143 var gutterType = "CodeMirror-gutter-performance"; | 143 var gutterType = "CodeMirror-gutter-performance"; |
144 var decorations = uiSourceCode.lineDecorations(WebInspector.LineLevelPro
file.LineDecorator.type); | 144 var decorations = uiSourceCode.lineDecorations(WebInspector.LineLevelPro
file.LineDecorator.type); |
145 textEditor.uninstallGutter(gutterType); | 145 textEditor.uninstallGutter(gutterType); |
146 if (!decorations) | 146 if (!decorations) |
147 return; | 147 return; |
148 textEditor.installGutter(gutterType, false); | 148 textEditor.installGutter(gutterType, false); |
149 for (var decoration of decorations.values()) { | 149 for (var decoration of decorations.values()) { |
150 var time = /** @type {number} */ (decoration.data()); | 150 var time = /** @type {number} */ (decoration.data()); |
151 var text = WebInspector.UIString("%.1f\xa0ms", time); | 151 var text = WebInspector.UIString("%.1f\xa0ms", time); |
152 var intensity = Number.constrain(Math.log10(1 + 2 * time) / 5, 0.02,
1); | 152 var intensity = Number.constrain(Math.log10(1 + 2 * time) / 5, 0.02,
1); |
153 var element = createElementWithClass("div", "text-editor-line-marker
-performance"); | 153 var element = createElementWithClass("div", "text-editor-line-marker
-performance"); |
154 element.textContent = text; | 154 element.textContent = text; |
155 element.style.backgroundColor = `hsla(44, 100%, 50%, ${intensity.toF
ixed(3)})`; | 155 element.style.backgroundColor = `hsla(44, 100%, 50%, ${intensity.toF
ixed(3)})`; |
156 textEditor.setGutterDecoration(decoration.line(), gutterType, elemen
t); | 156 textEditor.setGutterDecoration(decoration.line(), gutterType, elemen
t); |
157 } | 157 } |
158 } | 158 } |
159 } | 159 }; |
OLD | NEW |