OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
13 * distribution. | 13 * distribution. |
14 * * Neither the name of Google Inc. nor the names of its | 14 * * Neither the name of Google Inc. nor the names of its |
15 * contributors may be used to endorse or promote products derived from | 15 * contributors may be used to endorse or promote products derived from |
16 * this software without specific prior written permission. | 16 * this software without specific prior written permission. |
17 * | 17 * |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
| 30 /** |
| 31 * @implements {WebInspector.TimelineModeView} |
| 32 * @unrestricted |
| 33 */ |
| 34 WebInspector.MemoryCountersGraph = class extends WebInspector.CountersGraph { |
| 35 /** |
| 36 * @param {!WebInspector.TimelineModeViewDelegate} delegate |
| 37 * @param {!WebInspector.TimelineModel} model |
| 38 * @param {!Array<!WebInspector.TimelineModel.Filter>} filters |
| 39 */ |
| 40 constructor(delegate, model, filters) { |
| 41 super(delegate, model, filters); |
| 42 this._countersByName = {}; |
| 43 this._countersByName['jsHeapSizeUsed'] = this.createCounter( |
| 44 WebInspector.UIString('JS Heap'), WebInspector.UIString('JS Heap: %s'),
'hsl(220, 90%, 43%)', |
| 45 Number.bytesToString); |
| 46 this._countersByName['documents'] = this.createCounter( |
| 47 WebInspector.UIString('Documents'), WebInspector.UIString('Documents: %s
'), 'hsl(0, 90%, 43%)'); |
| 48 this._countersByName['nodes'] = |
| 49 this.createCounter(WebInspector.UIString('Nodes'), WebInspector.UIString
('Nodes: %s'), 'hsl(120, 90%, 43%)'); |
| 50 this._countersByName['jsEventListeners'] = this.createCounter( |
| 51 WebInspector.UIString('Listeners'), WebInspector.UIString('Listeners: %s
'), 'hsl(38, 90%, 43%)'); |
| 52 this._gpuMemoryCounter = this.createCounter( |
| 53 WebInspector.UIString('GPU Memory'), WebInspector.UIString('GPU Memory [
KB]: %s'), 'hsl(300, 90%, 43%)', |
| 54 Number.bytesToString); |
| 55 this._countersByName['gpuMemoryUsedKB'] = this._gpuMemoryCounter; |
| 56 } |
30 | 57 |
31 /** | 58 /** |
32 * @constructor | 59 * @override |
33 * @extends {WebInspector.CountersGraph} | 60 */ |
34 * @implements {WebInspector.TimelineModeView} | 61 refreshRecords() { |
35 * @param {!WebInspector.TimelineModeViewDelegate} delegate | 62 this.reset(); |
36 * @param {!WebInspector.TimelineModel} model | 63 var events = this._model.mainThreadEvents(); |
37 * @param {!Array<!WebInspector.TimelineModel.Filter>} filters | 64 for (var i = 0; i < events.length; ++i) { |
38 */ | 65 var event = events[i]; |
39 WebInspector.MemoryCountersGraph = function(delegate, model, filters) | 66 if (event.name !== WebInspector.TimelineModel.RecordType.UpdateCounters) |
40 { | 67 continue; |
41 WebInspector.CountersGraph.call(this, delegate, model, filters); | 68 |
42 this._countersByName = {}; | 69 var counters = event.args.data; |
43 this._countersByName["jsHeapSizeUsed"] = this.createCounter(WebInspector.UIS
tring("JS Heap"), WebInspector.UIString("JS Heap: %s"), "hsl(220, 90%, 43%)", Nu
mber.bytesToString); | 70 if (!counters) |
44 this._countersByName["documents"] = this.createCounter(WebInspector.UIString
("Documents"), WebInspector.UIString("Documents: %s"), "hsl(0, 90%, 43%)"); | 71 return; |
45 this._countersByName["nodes"] = this.createCounter(WebInspector.UIString("No
des"), WebInspector.UIString("Nodes: %s"), "hsl(120, 90%, 43%)"); | 72 for (var name in counters) { |
46 this._countersByName["jsEventListeners"] = this.createCounter(WebInspector.U
IString("Listeners"), WebInspector.UIString("Listeners: %s"), "hsl(38, 90%, 43%)
"); | 73 var counter = this._countersByName[name]; |
47 this._gpuMemoryCounter = this.createCounter(WebInspector.UIString("GPU Memor
y"), WebInspector.UIString("GPU Memory [KB]: %s"), "hsl(300, 90%, 43%)", Number.
bytesToString); | 74 if (counter) |
48 this._countersByName["gpuMemoryUsedKB"] = this._gpuMemoryCounter; | 75 counter.appendSample(event.startTime, counters[name]); |
| 76 } |
| 77 |
| 78 var gpuMemoryLimitCounterName = 'gpuMemoryLimitKB'; |
| 79 if (gpuMemoryLimitCounterName in counters) |
| 80 this._gpuMemoryCounter.setLimit(counters[gpuMemoryLimitCounterName]); |
| 81 } |
| 82 this.scheduleRefresh(); |
| 83 } |
49 }; | 84 }; |
50 | |
51 WebInspector.MemoryCountersGraph.prototype = { | |
52 /** | |
53 * @override | |
54 */ | |
55 refreshRecords: function() | |
56 { | |
57 this.reset(); | |
58 var events = this._model.mainThreadEvents(); | |
59 for (var i = 0; i < events.length; ++i) { | |
60 var event = events[i]; | |
61 if (event.name !== WebInspector.TimelineModel.RecordType.UpdateCount
ers) | |
62 continue; | |
63 | |
64 var counters = event.args.data; | |
65 if (!counters) | |
66 return; | |
67 for (var name in counters) { | |
68 var counter = this._countersByName[name]; | |
69 if (counter) | |
70 counter.appendSample(event.startTime, counters[name]); | |
71 } | |
72 | |
73 var gpuMemoryLimitCounterName = "gpuMemoryLimitKB"; | |
74 if (gpuMemoryLimitCounterName in counters) | |
75 this._gpuMemoryCounter.setLimit(counters[gpuMemoryLimitCounterNa
me]); | |
76 } | |
77 this.scheduleRefresh(); | |
78 }, | |
79 | |
80 __proto__: WebInspector.CountersGraph.prototype | |
81 }; | |
OLD | NEW |