OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2013 The Chromium Authors. All rights reserved. |
4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 --> | 6 --> |
7 | 7 |
8 <link rel="stylesheet" | 8 <link rel="stylesheet" |
9 href="/tracing/ui/extras/system_stats/system_stats_instance_track.css"> | 9 href="/tracing/ui/extras/system_stats/system_stats_instance_track.css"> |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 tr.ui.tracks.StackedBarsTrack.prototype.decorate.call(this, viewport); | 59 tr.ui.tracks.StackedBarsTrack.prototype.decorate.call(this, viewport); |
60 Polymer.dom(this).classList.add('tr-ui-e-system-stats-instance-track'); | 60 Polymer.dom(this).classList.add('tr-ui-e-system-stats-instance-track'); |
61 this.objectInstance_ = null; | 61 this.objectInstance_ = null; |
62 }, | 62 }, |
63 | 63 |
64 set objectInstances(objectInstances) { | 64 set objectInstances(objectInstances) { |
65 if (!objectInstances) { | 65 if (!objectInstances) { |
66 this.objectInstance_ = []; | 66 this.objectInstance_ = []; |
67 return; | 67 return; |
68 } | 68 } |
69 if (objectInstances.length != 1) | 69 if (objectInstances.length !== 1) |
70 throw new Error('Bad object instance count.'); | 70 throw new Error('Bad object instance count.'); |
71 this.objectInstance_ = objectInstances[0]; | 71 this.objectInstance_ = objectInstances[0]; |
72 if (this.objectInstance_ !== null) { | 72 if (this.objectInstance_ !== null) { |
73 this.computeRates_(this.objectInstance_.snapshots); | 73 this.computeRates_(this.objectInstance_.snapshots); |
74 this.maxStats_ = this.computeMaxStats_( | 74 this.maxStats_ = this.computeMaxStats_( |
75 this.objectInstance_.snapshots); | 75 this.objectInstance_.snapshots); |
76 } | 76 } |
77 }, | 77 }, |
78 | 78 |
79 computeRates_: function(snapshots) { | 79 computeRates_: function(snapshots) { |
80 for (var i = 0; i < snapshots.length; i++) { | 80 for (var i = 0; i < snapshots.length; i++) { |
81 var snapshot = snapshots[i]; | 81 var snapshot = snapshots[i]; |
82 var stats = snapshot.getStats(); | 82 var stats = snapshot.getStats(); |
83 var prevSnapshot; | 83 var prevSnapshot; |
84 var prevStats; | 84 var prevStats; |
85 | 85 |
86 if (i == 0) { | 86 if (i === 0) { |
87 // Deltas will be zero. | 87 // Deltas will be zero. |
88 prevSnapshot = snapshots[0]; | 88 prevSnapshot = snapshots[0]; |
89 } else { | 89 } else { |
90 prevSnapshot = snapshots[i - 1]; | 90 prevSnapshot = snapshots[i - 1]; |
91 } | 91 } |
92 prevStats = prevSnapshot.getStats(); | 92 prevStats = prevSnapshot.getStats(); |
93 var timeIntervalSeconds = (snapshot.ts - prevSnapshot.ts) / 1000; | 93 var timeIntervalSeconds = (snapshot.ts - prevSnapshot.ts) / 1000; |
94 // Prevent divide by zero. | 94 // Prevent divide by zero. |
95 if (timeIntervalSeconds == 0) | 95 if (timeIntervalSeconds === 0) |
96 timeIntervalSeconds = 1; | 96 timeIntervalSeconds = 1; |
97 | 97 |
98 this.computeRatesRecursive_(prevStats, stats, | 98 this.computeRatesRecursive_(prevStats, stats, |
99 timeIntervalSeconds); | 99 timeIntervalSeconds); |
100 } | 100 } |
101 }, | 101 }, |
102 | 102 |
103 computeRatesRecursive_: function(prevStats, stats, | 103 computeRatesRecursive_: function(prevStats, stats, |
104 timeIntervalSeconds) { | 104 timeIntervalSeconds) { |
105 for (var statName in stats) { | 105 for (var statName in stats) { |
106 if (stats[statName] instanceof Object) { | 106 if (stats[statName] instanceof Object) { |
107 this.computeRatesRecursive_(prevStats[statName], | 107 this.computeRatesRecursive_(prevStats[statName], |
108 stats[statName], | 108 stats[statName], |
109 timeIntervalSeconds); | 109 timeIntervalSeconds); |
110 } else { | 110 } else { |
111 if (statName == 'sectors_read') { | 111 if (statName === 'sectors_read') { |
112 stats['bytes_read_per_sec'] = (stats['sectors_read'] - | 112 stats['bytes_read_per_sec'] = (stats['sectors_read'] - |
113 prevStats['sectors_read']) * | 113 prevStats['sectors_read']) * |
114 512 / timeIntervalSeconds; | 114 512 / timeIntervalSeconds; |
115 } | 115 } |
116 if (statName == 'sectors_written') { | 116 if (statName === 'sectors_written') { |
117 stats['bytes_written_per_sec'] = | 117 stats['bytes_written_per_sec'] = |
118 (stats['sectors_written'] - | 118 (stats['sectors_written'] - |
119 prevStats['sectors_written']) * | 119 prevStats['sectors_written']) * |
120 512 / timeIntervalSeconds; | 120 512 / timeIntervalSeconds; |
121 } | 121 } |
122 if (statName == 'pgmajfault') { | 122 if (statName === 'pgmajfault') { |
123 stats['pgmajfault_per_sec'] = (stats['pgmajfault'] - | 123 stats['pgmajfault_per_sec'] = (stats['pgmajfault'] - |
124 prevStats['pgmajfault']) / | 124 prevStats['pgmajfault']) / |
125 timeIntervalSeconds; | 125 timeIntervalSeconds; |
126 } | 126 } |
127 if (statName == 'pswpin') { | 127 if (statName === 'pswpin') { |
128 stats['bytes_swpin_per_sec'] = (stats['pswpin'] - | 128 stats['bytes_swpin_per_sec'] = (stats['pswpin'] - |
129 prevStats['pswpin']) * | 129 prevStats['pswpin']) * |
130 1000 / timeIntervalSeconds; | 130 1000 / timeIntervalSeconds; |
131 } | 131 } |
132 if (statName == 'pswpout') { | 132 if (statName === 'pswpout') { |
133 stats['bytes_swpout_per_sec'] = (stats['pswpout'] - | 133 stats['bytes_swpout_per_sec'] = (stats['pswpout'] - |
134 prevStats['pswpout']) * | 134 prevStats['pswpout']) * |
135 1000 / timeIntervalSeconds; | 135 1000 / timeIntervalSeconds; |
136 } | 136 } |
137 } | 137 } |
138 } | 138 } |
139 }, | 139 }, |
140 | 140 |
141 computeMaxStats_: function(snapshots) { | 141 computeMaxStats_: function(snapshots) { |
142 var maxStats = new Object(); | 142 var maxStats = new Object(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 230 |
231 var left = snapshot.ts; | 231 var left = snapshot.ts; |
232 if (left > viewRWorld) | 232 if (left > viewRWorld) |
233 break; | 233 break; |
234 var leftView = vp.xWorldToView(left); | 234 var leftView = vp.xWorldToView(left); |
235 if (leftView < 0) | 235 if (leftView < 0) |
236 leftView = 0; | 236 leftView = 0; |
237 | 237 |
238 // Compute the edges for the column graph bar. | 238 // Compute the edges for the column graph bar. |
239 var right; | 239 var right; |
240 if (i != objectSnapshots.length - 1) { | 240 if (i !== objectSnapshots.length - 1) { |
241 right = objectSnapshots[i + 1].ts; | 241 right = objectSnapshots[i + 1].ts; |
242 } else { | 242 } else { |
243 // If this is the last snaphot of multiple snapshots, use the width of | 243 // If this is the last snaphot of multiple snapshots, use the width of |
244 // the previous snapshot for the width. | 244 // the previous snapshot for the width. |
245 if (objectSnapshots.length > 1) | 245 if (objectSnapshots.length > 1) |
246 right = objectSnapshots[i].ts + (objectSnapshots[i].ts - | 246 right = objectSnapshots[i].ts + (objectSnapshots[i].ts - |
247 objectSnapshots[i - 1].ts); | 247 objectSnapshots[i - 1].ts); |
248 else | 248 else |
249 // If there's only one snapshot, use max bounds as the width. | 249 // If there's only one snapshot, use max bounds as the width. |
250 right = this.objectInstance_.parent.model.bounds.max; | 250 right = this.objectInstance_.parent.model.bounds.max; |
251 } | 251 } |
252 | 252 |
253 var rightView = vp.xWorldToView(right); | 253 var rightView = vp.xWorldToView(right); |
254 if (rightView > width) | 254 if (rightView > width) |
255 rightView = width; | 255 rightView = width; |
256 | 256 |
257 // Floor the bounds to avoid a small gap between stacks. | 257 // Floor the bounds to avoid a small gap between stacks. |
258 leftView = Math.floor(leftView); | 258 leftView = Math.floor(leftView); |
259 rightView = Math.floor(rightView); | 259 rightView = Math.floor(rightView); |
260 | 260 |
261 // Descend into nested stats. | 261 // Descend into nested stats. |
262 this.drawStatBarsRecursive_(snapshot, | 262 this.drawStatBarsRecursive_(snapshot, |
263 leftView, | 263 leftView, |
264 rightView, | 264 rightView, |
265 height, | 265 height, |
266 trace, | 266 trace, |
267 maxStats, | 267 maxStats, |
268 currentY); | 268 currentY); |
269 | 269 |
270 if (i == lowIndex) | 270 if (i === lowIndex) |
271 this.drawStatNames_(leftView, height, currentY, '', maxStats); | 271 this.drawStatNames_(leftView, height, currentY, '', maxStats); |
272 } | 272 } |
273 ctx.lineWidth = 1; | 273 ctx.lineWidth = 1; |
274 }, | 274 }, |
275 | 275 |
276 drawStatBarsRecursive_: function(snapshot, | 276 drawStatBarsRecursive_: function(snapshot, |
277 leftView, | 277 leftView, |
278 rightView, | 278 rightView, |
279 height, | 279 height, |
280 stats, | 280 stats, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 ctx.textAlign = 'end'; | 325 ctx.textAlign = 'end'; |
326 ctx.font = '12px Arial'; | 326 ctx.font = '12px Arial'; |
327 ctx.fillStyle = '#000000'; | 327 ctx.fillStyle = '#000000'; |
328 for (var statName in maxStats) { | 328 for (var statName in maxStats) { |
329 if (maxStats[statName] instanceof Object) { | 329 if (maxStats[statName] instanceof Object) { |
330 currentY = this.drawStatNames_(leftView, height, currentY, | 330 currentY = this.drawStatNames_(leftView, height, currentY, |
331 statName, maxStats[statName]); | 331 statName, maxStats[statName]); |
332 } else { | 332 } else { |
333 var fullname = statName; | 333 var fullname = statName; |
334 | 334 |
335 if (prefix != '') | 335 if (prefix !== '') |
336 fullname = prefix + ' :: ' + statName; | 336 fullname = prefix + ' :: ' + statName; |
337 | 337 |
338 ctx.fillText(fullname, leftView - 10, currentY - height / 4); | 338 ctx.fillText(fullname, leftView - 10, currentY - height / 4); |
339 currentY += height; | 339 currentY += height; |
340 } | 340 } |
341 } | 341 } |
342 | 342 |
343 return currentY; | 343 return currentY; |
344 } | 344 } |
345 }; | 345 }; |
346 | 346 |
347 tr.ui.tracks.ObjectInstanceTrack.register( | 347 tr.ui.tracks.ObjectInstanceTrack.register( |
348 SystemStatsInstanceTrack, | 348 SystemStatsInstanceTrack, |
349 {typeName: 'base::TraceEventSystemStatsMonitor::SystemStats'}); | 349 {typeName: 'base::TraceEventSystemStatsMonitor::SystemStats'}); |
350 | 350 |
351 return { | 351 return { |
352 SystemStatsInstanceTrack: SystemStatsInstanceTrack | 352 SystemStatsInstanceTrack: SystemStatsInstanceTrack |
353 }; | 353 }; |
354 }); | 354 }); |
355 </script> | 355 </script> |
OLD | NEW |