mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1177558 - Change devtools memory module to return docshell time rather than Date.now() to match epoch from allocations, and add tests. r=fitzgen
This commit is contained in:
parent
642829b3c2
commit
d7a1b3ffdb
@ -371,9 +371,8 @@ RecordingModel.prototype = {
|
|||||||
case "allocations": {
|
case "allocations": {
|
||||||
if (!config.withAllocations) { break; }
|
if (!config.withAllocations) { break; }
|
||||||
let [{ sites, timestamps, frames, counts }] = data;
|
let [{ sites, timestamps, frames, counts }] = data;
|
||||||
let timeOffset = this._memoryStartTime * 1000;
|
let timeOffset = this._memoryStartTime;
|
||||||
let timeScale = 1000;
|
RecordingUtils.offsetAndScaleTimestamps(timestamps, timeOffset);
|
||||||
RecordingUtils.offsetAndScaleTimestamps(timestamps, timeOffset, timeScale);
|
|
||||||
pushAll(this._allocations.sites, sites);
|
pushAll(this._allocations.sites, sites);
|
||||||
pushAll(this._allocations.timestamps, timestamps);
|
pushAll(this._allocations.timestamps, timestamps);
|
||||||
pushAll(this._allocations.frames, frames);
|
pushAll(this._allocations.frames, frames);
|
||||||
|
@ -106,7 +106,9 @@ function offsetMarkerTimes(markers, timeOffset) {
|
|||||||
function offsetAndScaleTimestamps(timestamps, timeOffset, timeScale) {
|
function offsetAndScaleTimestamps(timestamps, timeOffset, timeScale) {
|
||||||
for (let i = 0, len = timestamps.length; i < len; i++) {
|
for (let i = 0, len = timestamps.length; i < len; i++) {
|
||||||
timestamps[i] -= timeOffset;
|
timestamps[i] -= timeOffset;
|
||||||
timestamps[i] /= timeScale;
|
if (timeScale) {
|
||||||
|
timestamps[i] /= timeScale;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
tags = devtools
|
tags = devtools
|
||||||
subsuite = devtools
|
subsuite = devtools
|
||||||
support-files =
|
support-files =
|
||||||
|
doc_allocs.html
|
||||||
doc_force_cc.html
|
doc_force_cc.html
|
||||||
doc_force_gc.html
|
doc_force_gc.html
|
||||||
doc_innerHTML.html
|
doc_innerHTML.html
|
||||||
|
@ -5,14 +5,14 @@
|
|||||||
* Tests that the memory call tree view renders content after recording.
|
* Tests that the memory call tree view renders content after recording.
|
||||||
*/
|
*/
|
||||||
function* spawnTest() {
|
function* spawnTest() {
|
||||||
let { panel } = yield initPerformance(SIMPLE_URL);
|
let { panel } = yield initPerformance(ALLOCS_URL);
|
||||||
let { EVENTS, DetailsView, MemoryCallTreeView } = panel.panelWin;
|
let { EVENTS, $$, PerformanceController, DetailsView, MemoryCallTreeView } = panel.panelWin;
|
||||||
|
|
||||||
// Enable memory to test.
|
// Enable memory to test.
|
||||||
Services.prefs.setBoolPref(ALLOCATIONS_PREF, true);
|
Services.prefs.setBoolPref(ALLOCATIONS_PREF, true);
|
||||||
|
|
||||||
yield startRecording(panel);
|
yield startRecording(panel);
|
||||||
yield busyWait(100);
|
yield waitUntil(() => PerformanceController.getCurrentRecording().getAllocations().timestamps.length);
|
||||||
yield stopRecording(panel);
|
yield stopRecording(panel);
|
||||||
|
|
||||||
let rendered = once(MemoryCallTreeView, EVENTS.MEMORY_CALL_TREE_RENDERED);
|
let rendered = once(MemoryCallTreeView, EVENTS.MEMORY_CALL_TREE_RENDERED);
|
||||||
@ -22,6 +22,8 @@ function* spawnTest() {
|
|||||||
|
|
||||||
ok(true, "MemoryCallTreeView rendered after recording is stopped.");
|
ok(true, "MemoryCallTreeView rendered after recording is stopped.");
|
||||||
|
|
||||||
|
ok($$("#memory-calltree-view .call-tree-item").length, "there are several allocations rendered.");
|
||||||
|
|
||||||
yield startRecording(panel);
|
yield startRecording(panel);
|
||||||
yield busyWait(100);
|
yield busyWait(100);
|
||||||
|
|
||||||
|
25
browser/devtools/performance/test/doc_allocs.html
Normal file
25
browser/devtools/performance/test/doc_allocs.html
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<!-- Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||||
|
<!doctype html>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
<title>Performance test page</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var allocs = [];
|
||||||
|
function test() {
|
||||||
|
for (var i = 0; i < 10; i++) {
|
||||||
|
allocs.push({});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent this script from being garbage collected.
|
||||||
|
window.setInterval(test, 1);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
@ -24,6 +24,7 @@ const FRAME_SCRIPT_UTILS_URL = "chrome://browser/content/devtools/frame-script-u
|
|||||||
const EXAMPLE_URL = "http://example.com/browser/browser/devtools/performance/test/";
|
const EXAMPLE_URL = "http://example.com/browser/browser/devtools/performance/test/";
|
||||||
const SIMPLE_URL = EXAMPLE_URL + "doc_simple-test.html";
|
const SIMPLE_URL = EXAMPLE_URL + "doc_simple-test.html";
|
||||||
const MARKERS_URL = EXAMPLE_URL + "doc_markers.html";
|
const MARKERS_URL = EXAMPLE_URL + "doc_markers.html";
|
||||||
|
const ALLOCS_URL = EXAMPLE_URL + "doc_allocs.html";
|
||||||
|
|
||||||
const MEMORY_SAMPLE_PROB_PREF = "devtools.performance.memory.sample-probability";
|
const MEMORY_SAMPLE_PROB_PREF = "devtools.performance.memory.sample-probability";
|
||||||
const MEMORY_MAX_LOG_LEN_PREF = "devtools.performance.memory.max-log-length";
|
const MEMORY_MAX_LOG_LEN_PREF = "devtools.performance.memory.max-log-length";
|
||||||
|
@ -95,7 +95,7 @@ let Memory = exports.Memory = Class({
|
|||||||
|
|
||||||
_clearDebuggees: function() {
|
_clearDebuggees: function() {
|
||||||
if (this._dbg) {
|
if (this._dbg) {
|
||||||
if (this.dbg.memory.trackingAllocationSites) {
|
if (this.isRecordingAllocations()) {
|
||||||
this.dbg.memory.drainAllocationsLog();
|
this.dbg.memory.drainAllocationsLog();
|
||||||
}
|
}
|
||||||
this._clearFrames();
|
this._clearFrames();
|
||||||
@ -104,7 +104,7 @@ let Memory = exports.Memory = Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_clearFrames: function() {
|
_clearFrames: function() {
|
||||||
if (this.dbg.memory.trackingAllocationSites) {
|
if (this.isRecordingAllocations()) {
|
||||||
this._frameCache.clearFrames();
|
this._frameCache.clearFrames();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -114,7 +114,7 @@ let Memory = exports.Memory = Class({
|
|||||||
*/
|
*/
|
||||||
_onWindowReady: function({ isTopLevel }) {
|
_onWindowReady: function({ isTopLevel }) {
|
||||||
if (this.state == "attached") {
|
if (this.state == "attached") {
|
||||||
if (isTopLevel && this.dbg.memory.trackingAllocationSites) {
|
if (isTopLevel && this.isRecordingAllocations()) {
|
||||||
this._clearDebuggees();
|
this._clearDebuggees();
|
||||||
this._frameCache.initFrames();
|
this._frameCache.initFrames();
|
||||||
}
|
}
|
||||||
@ -122,6 +122,14 @@ let Memory = exports.Memory = Class({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a boolean indicating whether or not allocation
|
||||||
|
* sites are being tracked.
|
||||||
|
*/
|
||||||
|
isRecordingAllocations: function () {
|
||||||
|
return this.dbg.memory.trackingAllocationSites;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take a census of the heap. See js/src/doc/Debugger/Debugger.Memory.md for
|
* Take a census of the heap. See js/src/doc/Debugger/Debugger.Memory.md for
|
||||||
* more information.
|
* more information.
|
||||||
@ -146,8 +154,8 @@ let Memory = exports.Memory = Class({
|
|||||||
* resetting the timer.
|
* resetting the timer.
|
||||||
*/
|
*/
|
||||||
startRecordingAllocations: expectState("attached", function(options = {}) {
|
startRecordingAllocations: expectState("attached", function(options = {}) {
|
||||||
if (this.dbg.memory.trackingAllocationSites) {
|
if (this.isRecordingAllocations()) {
|
||||||
return Date.now();
|
return this._getCurrentTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
this._frameCache.initFrames();
|
this._frameCache.initFrames();
|
||||||
@ -171,13 +179,16 @@ let Memory = exports.Memory = Class({
|
|||||||
}
|
}
|
||||||
this.dbg.memory.trackingAllocationSites = true;
|
this.dbg.memory.trackingAllocationSites = true;
|
||||||
|
|
||||||
return Date.now();
|
return this._getCurrentTime();
|
||||||
}, `starting recording allocations`),
|
}, `starting recording allocations`),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop recording allocation sites.
|
* Stop recording allocation sites.
|
||||||
*/
|
*/
|
||||||
stopRecordingAllocations: expectState("attached", function() {
|
stopRecordingAllocations: expectState("attached", function() {
|
||||||
|
if (!this.isRecordingAllocations()) {
|
||||||
|
return this._getCurrentTime();
|
||||||
|
}
|
||||||
this.dbg.memory.trackingAllocationSites = false;
|
this.dbg.memory.trackingAllocationSites = false;
|
||||||
this._clearFrames();
|
this._clearFrames();
|
||||||
|
|
||||||
@ -186,7 +197,7 @@ let Memory = exports.Memory = Class({
|
|||||||
this._poller = null;
|
this._poller = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Date.now();
|
return this._getCurrentTime();
|
||||||
}, `stopping recording allocations`),
|
}, `stopping recording allocations`),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -380,4 +391,12 @@ let Memory = exports.Memory = Class({
|
|||||||
events.emit(this, "allocations", this.getAllocations());
|
events.emit(this, "allocations", this.getAllocations());
|
||||||
this._poller.arm();
|
this._poller.arm();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accesses the docshell to return the current process time.
|
||||||
|
*/
|
||||||
|
_getCurrentTime: function () {
|
||||||
|
return (this.parent.isRootActor ? this.parent.docShell : this.parent.originalDocShell).now();
|
||||||
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user