| 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 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 var lowerOffset = 3 * ratio; | 61 var lowerOffset = 3 * ratio; |
| 62 var maxUsedHeapSize = 0; | 62 var maxUsedHeapSize = 0; |
| 63 var minUsedHeapSize = 100000000000; | 63 var minUsedHeapSize = 100000000000; |
| 64 var minTime = this._model.minimumRecordTime(); | 64 var minTime = this._model.minimumRecordTime(); |
| 65 var maxTime = this._model.maximumRecordTime(); | 65 var maxTime = this._model.maximumRecordTime(); |
| 66 /** | 66 /** |
| 67 * @param {!WebInspector.TimelineModel.Record} record | 67 * @param {!WebInspector.TimelineModel.Record} record |
| 68 */ | 68 */ |
| 69 function calculateMinMaxSizes(record) | 69 function calculateMinMaxSizes(record) |
| 70 { | 70 { |
| 71 if (record.type() !== WebInspector.TimelineModel.RecordType.UpdateCo
unters) | 71 var counters = record.counters(); |
| 72 return; | 72 if (!counters || !counters.jsHeapSizeUsed) |
| 73 var counters = record.data(); | |
| 74 if (!counters.jsHeapSizeUsed) | |
| 75 return; | 73 return; |
| 76 maxUsedHeapSize = Math.max(maxUsedHeapSize, counters.jsHeapSizeUsed)
; | 74 maxUsedHeapSize = Math.max(maxUsedHeapSize, counters.jsHeapSizeUsed)
; |
| 77 minUsedHeapSize = Math.min(minUsedHeapSize, counters.jsHeapSizeUsed)
; | 75 minUsedHeapSize = Math.min(minUsedHeapSize, counters.jsHeapSizeUsed)
; |
| 78 } | 76 } |
| 79 this._model.forAllRecords(calculateMinMaxSizes); | 77 this._model.forAllRecords(calculateMinMaxSizes); |
| 80 minUsedHeapSize = Math.min(minUsedHeapSize, maxUsedHeapSize); | 78 minUsedHeapSize = Math.min(minUsedHeapSize, maxUsedHeapSize); |
| 81 | 79 |
| 82 var lineWidth = 1; | 80 var lineWidth = 1; |
| 83 var width = this._canvas.width; | 81 var width = this._canvas.width; |
| 84 var height = this._canvas.height - lowerOffset; | 82 var height = this._canvas.height - lowerOffset; |
| 85 var xFactor = width / (maxTime - minTime); | 83 var xFactor = width / (maxTime - minTime); |
| 86 var yFactor = (height - lineWidth) / Math.max(maxUsedHeapSize - minUsedH
eapSize, 1); | 84 var yFactor = (height - lineWidth) / Math.max(maxUsedHeapSize - minUsedH
eapSize, 1); |
| 87 | 85 |
| 88 var histogram = new Array(width); | 86 var histogram = new Array(width); |
| 89 | 87 |
| 90 /** | 88 /** |
| 91 * @param {!WebInspector.TimelineModel.Record} record | 89 * @param {!WebInspector.TimelineModel.Record} record |
| 92 */ | 90 */ |
| 93 function buildHistogram(record) | 91 function buildHistogram(record) |
| 94 { | 92 { |
| 95 if (record.type() !== WebInspector.TimelineModel.RecordType.UpdateCo
unters) | 93 var counters = record.counters(); |
| 96 return; | 94 if (!counters || !counters.jsHeapSizeUsed) |
| 97 var counters = record.data(); | |
| 98 if (!counters.jsHeapSizeUsed) | |
| 99 return; | 95 return; |
| 100 var x = Math.round((record.endTime() - minTime) * xFactor); | 96 var x = Math.round((record.endTime() - minTime) * xFactor); |
| 101 var y = Math.round((counters.jsHeapSizeUsed - minUsedHeapSize) * yFa
ctor); | 97 var y = Math.round((counters.jsHeapSizeUsed - minUsedHeapSize) * yFa
ctor); |
| 102 histogram[x] = Math.max(histogram[x] || 0, y); | 98 histogram[x] = Math.max(histogram[x] || 0, y); |
| 103 } | 99 } |
| 104 this._model.forAllRecords(buildHistogram); | 100 this._model.forAllRecords(buildHistogram); |
| 105 | 101 |
| 106 var ctx = this._context; | 102 var ctx = this._context; |
| 107 var heightBeyondView = height + lowerOffset + lineWidth; | 103 var heightBeyondView = height + lowerOffset + lineWidth; |
| 108 | 104 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 135 ctx.fill(); | 131 ctx.fill(); |
| 136 ctx.lineWidth = lineWidth; | 132 ctx.lineWidth = lineWidth; |
| 137 ctx.strokeStyle = "hsl(220, 90%, 70%)"; | 133 ctx.strokeStyle = "hsl(220, 90%, 70%)"; |
| 138 ctx.stroke(); | 134 ctx.stroke(); |
| 139 | 135 |
| 140 this._heapSizeLabel.textContent = WebInspector.UIString("%s \u2013 %s",
Number.bytesToString(minUsedHeapSize), Number.bytesToString(maxUsedHeapSize)); | 136 this._heapSizeLabel.textContent = WebInspector.UIString("%s \u2013 %s",
Number.bytesToString(minUsedHeapSize), Number.bytesToString(maxUsedHeapSize)); |
| 141 }, | 137 }, |
| 142 | 138 |
| 143 __proto__: WebInspector.TimelineOverviewBase.prototype | 139 __proto__: WebInspector.TimelineOverviewBase.prototype |
| 144 } | 140 } |
| OLD | NEW |