Bug 1374333 - Use TalosContentProfiler to fix profiling in tscroll tests. r?rwood
MozReview-Commit-ID: B7ymFcpTMSC
--- a/testing/talos/talos/pageloader/chrome/tscroll.js
+++ b/testing/talos/talos/pageloader/chrome/tscroll.js
@@ -1,12 +1,20 @@
// Note: This file is used at both tscrollx and tp5o_scroll. With the former as
// unprivileged code.
// - Please make sure that any changes apply cleanly to all use cases.
+if (typeof(TalosContentProfiler) == "undefined") {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ } catch (e) {}
+ Components.utils.import("resource://gre/modules/Services.jsm");
+ Services.scriptloader.loadSubScript("chrome://talos-powers-content/content/TalosContentProfiler.js");
+}
+
function testScroll(target, stepSize, opt_reportFunc, opt_numSteps) {
var win;
if (target == "content") {
target = content.wrappedJSObject;
win = content;
} else {
win = window;
}
@@ -160,51 +168,55 @@ function testScroll(target, stepSize, op
var duration = now - lastScrollTime;
lastScrollTime = now;
durations.push(duration);
doScrollTick();
/* stop scrolling if we can't scroll more, or if we've reached requested number of steps */
if ((getPos() == lastScrollPos) || (opt_numSteps && (durations.length >= (opt_numSteps + 2)))) {
- if (typeof(Profiler) !== "undefined") {
- Profiler.pause();
+ let profilerPaused = Promise.resolve();
+ if (typeof(TalosContentProfiler) !== "undefined") {
+ profilerPaused = TalosContentProfiler.pause(testBaseName, true);
}
- // Note: The first (1-5) intervals WILL be longer than the rest.
- // First interval might include initial rendering and be extra slow.
- // Also requestAnimationFrame needs to sync (optimally in 1 frame) after long frames.
- // Suggested: Ignore the first 5 intervals.
+ profilerPaused.then(() => {
+ // Note: The first (1-5) intervals WILL be longer than the rest.
+ // First interval might include initial rendering and be extra slow.
+ // Also requestAnimationFrame needs to sync (optimally in 1 frame) after long frames.
+ // Suggested: Ignore the first 5 intervals.
- durations.pop(); // Last step was 0.
- durations.pop(); // and the prev one was shorter and with end-of-page logic, ignore both.
+ durations.pop(); // Last step was 0.
+ durations.pop(); // and the prev one was shorter and with end-of-page logic, ignore both.
- if (win.talosDebug)
- win.talosDebug.displayData = true; // In a browser: also display all data points.
+ if (win.talosDebug)
+ win.talosDebug.displayData = true; // In a browser: also display all data points.
- // For analysis (otherwise, it's too many data points for talos):
- var sum = 0;
- for (var i = 0; i < durations.length; i++)
- sum += Number(durations[i]);
+ // For analysis (otherwise, it's too many data points for talos):
+ var sum = 0;
+ for (var i = 0; i < durations.length; i++)
+ sum += Number(durations[i]);
- // Report average interval or (failsafe) 0 if no intervls were recorded
- result.values.push(durations.length ? sum / durations.length : 0);
- result.names.push(testBaseName);
- resolve();
+ // Report average interval or (failsafe) 0 if no intervls were recorded
+ result.values.push(durations.length ? sum / durations.length : 0);
+ result.names.push(testBaseName);
+ resolve();
+ });
return;
}
lastScrollPos = getPos();
rAF(tick);
}
- if (typeof(Profiler) !== "undefined") {
- Profiler.resume();
+ if (typeof(TalosContentProfiler) !== "undefined") {
+ TalosContentProfiler.resume(testBaseName, true).then(() => {
+ rAF(tick);
+ });
}
- rAF(tick);
});
}
function P_testAPZScroll() {
var APZ_MEASURE_MS = 1000;
function startFrameTimeRecording(cb) {
TalosPowersParent.exec("startFrameTimeRecording", null, cb, win);
--- a/testing/talos/talos/tests/scroll/iframe.svg
+++ b/testing/talos/talos/tests/scroll/iframe.svg
@@ -29,11 +29,11 @@
}
}
</script>
<foreignObject x="5%" height="85%" width="90%">
<iframe onload="iframeLoad();" id="ifrm" width="99%" height="99%" xmlns="http://www.w3.org/1999/xhtml" src="drac.htm"/>
</foreignObject>
<!-- this has to come after the iframe for some reason -->
<script type="text/javascript" xlink:href="../../scripts/talos-debug.js"/>
- <script type="text/javascript" xlink:href="../../scripts/Profiler.js"/>
+ <script language="Javascript" type="text/javascript" src="chrome://talos-powers-content/content/TalosContentProfiler.js"></script>
<script type="text/javascript" xlink:href="../../pageloader/chrome/tscroll.js"/>
</svg>
--- a/testing/talos/talos/tests/scroll/reader.htm
+++ b/testing/talos/talos/tests/scroll/reader.htm
@@ -1,14 +1,14 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Perf test case</title>
<link type="text/css" rel="stylesheet" href="reader.css">
-<script src="../../scripts/Profiler.js" type="text/javascript"></script>
+<script language="Javascript" type="text/javascript" src="chrome://talos-powers-content/content/TalosContentProfiler.js"></script>
<script src="../../pageloader/chrome/tscroll.js" type="text/javascript"></script>
<!--
This resembles the layout of Google Reader as of 2009-11-23
and exposed bug 530686.
-->
</head>
<body onload = "testScroll(document.getElementById('entries'), 5)">
<table id="chrome-viewer-container">
--- a/testing/talos/talos/tests/scroll/tiled-downscale.html
+++ b/testing/talos/talos/tests/scroll/tiled-downscale.html
@@ -3,17 +3,17 @@
body { background: url("strips.png");
-moz-background-size: 2.5px;
-webkit-background-size: 2.5px;
background-size: 2.5px;
margin-left: 160pt;
width: 400pt;
}
</style>
- <script src="../../scripts/Profiler.js" type="text/javascript"></script>
+ <script language="Javascript" type="text/javascript" src="chrome://talos-powers-content/content/TalosContentProfiler.js"></script>
<script src="../../pageloader/chrome/tscroll.js" type="text/javascript"></script>
</head>
<body onload = "testScroll(window, 5)">
<P>
3 May. Bistritz.--Left Munich at 8:35 P.M., on 1st May, arriving at
Vienna early next morning; should have arrived at 6:46, but train was
an hour late. Buda-Pesth seems a wonderful place, from the glimpse
which I got of it from the train and the little I could walk through
--- a/testing/talos/talos/tests/scroll/tiled-fixed-downscale.html
+++ b/testing/talos/talos/tests/scroll/tiled-fixed-downscale.html
@@ -4,17 +4,17 @@
-moz-background-size: 2.5px;
-webkit-background-size: 2.5px;
background-size: 2.5px;
background-attachment: fixed;
margin-left: 160pt;
width: 400pt;
}
</style>
- <script src="../../scripts/Profiler.js" type="text/javascript"></script>
+ <script language="Javascript" type="text/javascript" src="chrome://talos-powers-content/content/TalosContentProfiler.js"></script>
<script src="../../pageloader/chrome/tscroll.js" type="text/javascript"></script>
</head>
<body onload = "testScroll(window, 5)">
<P>
3 May. Bistritz.--Left Munich at 8:35 P.M., on 1st May, arriving at
Vienna early next morning; should have arrived at 6:46, but train was
an hour late. Buda-Pesth seems a wonderful place, from the glimpse
which I got of it from the train and the little I could walk through
--- a/testing/talos/talos/tests/scroll/tiled-fixed.html
+++ b/testing/talos/talos/tests/scroll/tiled-fixed.html
@@ -1,17 +1,17 @@
<head>
<style>
body { background: url("strips.png");
background-attachment: fixed;
margin-left: 160pt;
width: 400pt;
}
</style>
- <script src="../../scripts/Profiler.js" type="text/javascript"></script>
+ <script language="Javascript" type="text/javascript" src="chrome://talos-powers-content/content/TalosContentProfiler.js"></script>
<script src="../../pageloader/chrome/tscroll.js" type="text/javascript"></script>
</head>
<body onload = "testScroll(window, 5)">
<P>
3 May. Bistritz.--Left Munich at 8:35 P.M., on 1st May, arriving at
Vienna early next morning; should have arrived at 6:46, but train was
an hour late. Buda-Pesth seems a wonderful place, from the glimpse
which I got of it from the train and the little I could walk through
--- a/testing/talos/talos/tests/scroll/tiled.html
+++ b/testing/talos/talos/tests/scroll/tiled.html
@@ -1,16 +1,16 @@
<head>
<style>
body { background: url("strips.png");
margin-left: 160pt;
width: 400pt;
}
</style>
- <script src="../../scripts/Profiler.js" type="text/javascript"></script>
+ <script language="Javascript" type="text/javascript" src="chrome://talos-powers-content/content/TalosContentProfiler.js"></script>
<script src="../../pageloader/chrome/tscroll.js" type="text/javascript"></script>
</head>
<body onload = "testScroll(window, 5)">
<P>
3 May. Bistritz.--Left Munich at 8:35 P.M., on 1st May, arriving at
Vienna early next morning; should have arrived at 6:46, but train was
an hour late. Buda-Pesth seems a wonderful place, from the glimpse
which I got of it from the train and the little I could walk through