mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 02:57:38 +00:00
Bug 1132765 - Pass through performance memory options for 'probability' and 'maxLogLength' from the front to the memory actor. r=vp
--HG-- rename : browser/devtools/shared/test/browser_prefs.js => browser/devtools/shared/test/browser_prefs-01.js
This commit is contained in:
parent
e52919aefc
commit
53c080ad33
@ -1461,6 +1461,8 @@ pref("devtools.profiler.ui.show-platform-data", false);
|
||||
pref("devtools.profiler.ui.show-idle-blocks", true);
|
||||
|
||||
// The default Performance UI settings
|
||||
pref("devtools.performance.memory.sample-probability", "0.05");
|
||||
pref("devtools.performance.memory.max-log-length", 2147483647); // Math.pow(2,31) - 1
|
||||
pref("devtools.performance.timeline.hidden-markers", "[]");
|
||||
pref("devtools.performance.ui.invert-call-tree", true);
|
||||
pref("devtools.performance.ui.invert-flame-graph", false);
|
||||
|
@ -329,7 +329,7 @@ PerformanceFront.prototype = {
|
||||
return 0;
|
||||
}
|
||||
yield this._request("memory", "attach");
|
||||
let memoryStartTime = yield this._request("memory", "startRecordingAllocations");
|
||||
let memoryStartTime = yield this._request("memory", "startRecordingAllocations", options);
|
||||
yield this._pullAllocationSites();
|
||||
return memoryStartTime;
|
||||
}),
|
||||
|
@ -182,7 +182,9 @@ let PerformanceController = {
|
||||
// ToolbarView, so that they may be accessible via the "gear" menu.
|
||||
// Every other pref should be registered here.
|
||||
this._nonBooleanPrefs = new ViewHelpers.Prefs("devtools.performance", {
|
||||
"hidden-markers": ["Json", "timeline.hidden-markers"]
|
||||
"hidden-markers": ["Json", "timeline.hidden-markers"],
|
||||
"memory-sample-probability": ["Float", "memory.sample-probability"],
|
||||
"memory-max-log-length": ["Int", "memory.max-log-length"]
|
||||
});
|
||||
|
||||
this._nonBooleanPrefs.registerObserver();
|
||||
@ -262,11 +264,13 @@ let PerformanceController = {
|
||||
let withMemory = this.getOption("enable-memory");
|
||||
let withTicks = this.getOption("enable-framerate");
|
||||
let withAllocations = this.getOption("enable-memory");
|
||||
let probability = this.getPref("memory-sample-probability");
|
||||
let maxLogLength = this.getPref("memory-max-log-length");
|
||||
|
||||
let recording = this._createRecording({ withMemory, withTicks, withAllocations });
|
||||
let recording = this._createRecording({ withMemory, withTicks, withAllocations, probability, maxLogLength });
|
||||
|
||||
this.emit(EVENTS.RECORDING_WILL_START, recording);
|
||||
yield recording.startRecording({ withTicks, withMemory, withAllocations });
|
||||
yield recording.startRecording({ withMemory, withTicks, withAllocations, probability, maxLogLength });
|
||||
this.emit(EVENTS.RECORDING_STARTED, recording);
|
||||
|
||||
this.setCurrentRecording(recording);
|
||||
|
@ -54,6 +54,7 @@ support-files =
|
||||
[browser_perf-options-enable-memory-01.js]
|
||||
[browser_perf-options-enable-memory-02.js]
|
||||
[browser_perf-options-enable-framerate.js]
|
||||
[browser_perf-options-allocations.js]
|
||||
[browser_perf-overview-render-01.js]
|
||||
[browser_perf-overview-render-02.js]
|
||||
[browser_perf-overview-render-03.js]
|
||||
|
@ -0,0 +1,33 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
|
||||
/**
|
||||
* Tests that setting the `devtools.performance.memory.` prefs propagate to the memory actor.
|
||||
*/
|
||||
function spawnTest () {
|
||||
let { panel } = yield initPerformance(SIMPLE_URL);
|
||||
let { EVENTS, PerformanceController, $, gFront } = panel.panelWin;
|
||||
Services.prefs.setBoolPref(MEMORY_PREF, true);
|
||||
|
||||
let originalProbability = Services.prefs.getCharPref("devtools.performance.memory.sample-probability");
|
||||
let originalLogLength = Services.prefs.getIntPref("devtools.performance.memory.max-log-length");
|
||||
|
||||
Services.prefs.setCharPref("devtools.performance.memory.sample-probability", "0.213");
|
||||
Services.prefs.setIntPref("devtools.performance.memory.max-log-length", 777777);
|
||||
|
||||
yield startRecording(panel);
|
||||
|
||||
let { probability, maxLogLength } = yield gFront._request("memory", "getAllocationsSettings");
|
||||
|
||||
yield stopRecording(panel);
|
||||
|
||||
is(probability, 0.213, "allocations probability option is set on memory actor");
|
||||
is(maxLogLength, 777777, "allocations max log length option is set on memory actor");
|
||||
|
||||
Services.prefs.setBoolPref(MEMORY_PREF, false);
|
||||
Services.prefs.setCharPref("devtools.performance.memory.sample-probability", originalProbability);
|
||||
Services.prefs.setIntPref("devtools.performance.memory.max-log-length", originalLogLength);
|
||||
yield teardown(panel);
|
||||
finish();
|
||||
}
|
@ -58,7 +58,8 @@ skip-if = e10s # Layouthelpers test should not run in a content page.
|
||||
[browser_options-view-01.js]
|
||||
[browser_outputparser.js]
|
||||
skip-if = e10s # Test intermittently fails with e10s. Bug 1124162.
|
||||
[browser_prefs.js]
|
||||
[browser_prefs-01.js]
|
||||
[browser_prefs-02.js]
|
||||
[browser_require_basic.js]
|
||||
[browser_spectrum.js]
|
||||
[browser_theme.js]
|
||||
|
39
browser/devtools/shared/test/browser_prefs-02.js
Normal file
39
browser/devtools/shared/test/browser_prefs-02.js
Normal file
@ -0,0 +1,39 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Tests that ViewHelpers.Prefs work properly with custom types of Float and Json.
|
||||
|
||||
let {ViewHelpers} = Cu.import("resource:///modules/devtools/ViewHelpers.jsm", {});
|
||||
|
||||
function test() {
|
||||
let originalJson = Services.prefs.getCharPref("devtools.performance.timeline.hidden-markers");
|
||||
let originalFloat = Services.prefs.getCharPref("devtools.performance.memory.sample-probability");
|
||||
|
||||
let Prefs = new ViewHelpers.Prefs("devtools.performance", {
|
||||
"float": ["Float", "memory.sample-probability"],
|
||||
"json": ["Json", "timeline.hidden-markers"]
|
||||
});
|
||||
|
||||
Prefs.registerObserver();
|
||||
|
||||
// Float
|
||||
Services.prefs.setCharPref("devtools.performance.timeline.hidden-markers", "{\"a\":1}");
|
||||
is(Prefs.json.a, 1, "The JSON pref value is correctly casted on get.");
|
||||
|
||||
Prefs.json = { b: 2 };
|
||||
is(Prefs.json.a, undefined, "The JSON pref value is correctly casted on set (1).");
|
||||
is(Prefs.json.b, 2, "The JSON pref value is correctly casted on set (2).");
|
||||
|
||||
// Float
|
||||
Services.prefs.setCharPref("devtools.performance.memory.sample-probability", "3.14");
|
||||
is(Prefs.float, 3.14, "The float pref value is correctly casted on get.");
|
||||
|
||||
Prefs.float = 6.28;
|
||||
is(Prefs.float, 6.28, "The float pref value is correctly casted on set.");
|
||||
|
||||
Prefs.unregisterObserver();
|
||||
|
||||
Services.prefs.setCharPref("devtools.performance.timeline.hidden-markers", originalJson);
|
||||
Services.prefs.setCharPref("devtools.performance.memory.sample-probability", originalFloat);
|
||||
finish();
|
||||
}
|
@ -390,7 +390,8 @@ ViewHelpers.L10N.prototype = {
|
||||
* let prefs = new ViewHelpers.Prefs("root.path.to.branch", {
|
||||
* myIntPref: ["Int", "leaf.path.to.my-int-pref"],
|
||||
* myCharPref: ["Char", "leaf.path.to.my-char-pref"],
|
||||
* myJsonPref: ["Json", "leaf.path.to.my-json-pref"]
|
||||
* myJsonPref: ["Json", "leaf.path.to.my-json-pref"],
|
||||
* myFloatPref: ["Float", "leaf.path.to.my-float-pref"]
|
||||
* ...
|
||||
* });
|
||||
*
|
||||
@ -477,8 +478,8 @@ ViewHelpers.Prefs.prototype = {
|
||||
|
||||
/**
|
||||
* Maps a property name to a pref, defining lazy getters and setters.
|
||||
* Supported types are "Bool", "Char", "Int" and "Json" (which is basically
|
||||
* just sugar for "Char" using the standard JSON serializer).
|
||||
* Supported types are "Bool", "Char", "Int", "Float" (sugar around "Char" type and casting),
|
||||
* and "Json" (which is basically just sugar for "Char" using the standard JSON serializer).
|
||||
*
|
||||
* @param string aAccessorName
|
||||
* @param string aType
|
||||
@ -494,6 +495,10 @@ ViewHelpers.Prefs.prototype = {
|
||||
this._map(aAccessorName, "Char", aPrefsRoot, aPrefName, { in: JSON.parse, out: JSON.stringify });
|
||||
return;
|
||||
}
|
||||
if (aType == "Float") {
|
||||
this._map(aAccessorName, "Char", aPrefsRoot, aPrefName, { in: Number.parseFloat, out: (n) => n + ""});
|
||||
return;
|
||||
}
|
||||
|
||||
Object.defineProperty(this, aAccessorName, {
|
||||
get: () => aSerializer.in(this._get(aType, aPrefsRoot, aPrefName)),
|
||||
|
@ -182,6 +182,7 @@ let MemoryActor = protocol.ActorClass({
|
||||
*/
|
||||
startRecordingAllocations: method(expectState("attached", function(options = {}) {
|
||||
this._frameCache.initFrames();
|
||||
|
||||
this.dbg.memory.allocationSamplingProbability = options.probability != null
|
||||
? options.probability
|
||||
: 1.0;
|
||||
@ -219,6 +220,23 @@ let MemoryActor = protocol.ActorClass({
|
||||
}
|
||||
}),
|
||||
|
||||
/**
|
||||
* Return settings used in `startRecordingAllocations` for `probability`
|
||||
* and `maxLogLength`. Currently only uses in tests.
|
||||
*/
|
||||
getAllocationsSettings: method(expectState("attached", function() {
|
||||
return {
|
||||
maxLogLength: this.dbg.memory.maxAllocationsLogLength,
|
||||
probability: this.dbg.memory.allocationSamplingProbability
|
||||
};
|
||||
},
|
||||
`getting allocations settings`), {
|
||||
request: {},
|
||||
response: {
|
||||
options: RetVal(0, "json")
|
||||
}
|
||||
}),
|
||||
|
||||
/**
|
||||
* Get a list of the most recent allocations since the last time we got
|
||||
* allocations, as well as a summary of all allocations since we've been
|
||||
|
Loading…
Reference in New Issue
Block a user