Bug 859155 - Tests for gfx, deck shifting, composition, and tabs. r=mbrubeck, sfoster

This commit is contained in:
Jim Mathies 2013-06-20 14:50:22 -05:00
parent 4b14b6b5e2
commit 4056bfdb6c
10 changed files with 526 additions and 7 deletions

View File

@ -0,0 +1,40 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DEPTH = @DEPTH@
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = @relativesrcdir@
include $(DEPTH)/config/autoconf.mk
ifndef MOZ_DEBUG
PERF_TEST_FILES = \
../mochitest/head.js \
perfhelpers.js \
browser_miscgfx_01.js \
browser_tabs_01.js \
browser_deck_01.js \
browser_msgmgr_01.js \
msgmanagerecho.js \
browser_layers_01.js \
$(NULL)
PERF_RESOURCE_FILES = \
res/ripples.html \
res/scroll_test.html \
res/tidevideo.html \
res/tide.mp4 \
res/divs_test.html \
res/fx.png \
$(NULL)
PERF_TEST_DEST := $(DEPTH)/_tests/testing/mochitest/metro/$(relativesrcdir)
PERF_RESOURCE_DEST := $(DEPTH)/_tests/testing/mochitest/metro/$(relativesrcdir)/res
INSTALL_TARGETS += PERF_TEST PERF_RESOURCE
endif
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,56 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function test() {
let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
Services.scriptloader.loadSubScript(testDir + "/perfhelpers.js", this);
runTests();
}
gTests.push({
desc: "deck offset",
run: function run() {
yield addTab("about:mozilla");
yield hideContextUI();
yield waitForMs(5000);
let shiftDataSet = new Array();
let paintDataSet = new Array();
let stopwatch = new StopWatch();
var paintCount = 0;
function onPaint() {
paintCount++;
}
for (let idx = 0; idx < 10; idx++) {
window.addEventListener("MozAfterPaint", onPaint, true);
stopwatch.start();
let promise = waitForEvent(window, "MozDeckOffsetChanged");
ContentAreaObserver._shiftBrowserDeck(300);
yield promise;
promise = waitForEvent(window, "MozDeckOffsetChanged");
ContentAreaObserver._shiftBrowserDeck(0);
yield promise;
stopwatch.stop();
yield waitForMs(500);
window.removeEventListener("MozAfterPaint", onPaint, true);
shiftDataSet.push(stopwatch.time());
paintDataSet.push(paintCount);
paintCount = 0;
}
PerfTest.declareTest("ecb5fbec-0b3d-490f-8d4a-13fa8963e54a",
"shift browser deck", "browser", "ux",
"Triggers multiple SKB deck shifting operations using an offset " +
"value of 300px. Measures total time in milliseconds for a up/down " +
"shift operation plus the total number of paints. Strips outliers.");
let shiftAverage = PerfTest.computeAverage(shiftDataSet, { stripOutliers: true });
let paintAverage = PerfTest.computeAverage(paintDataSet, { stripOutliers: true });
PerfTest.declareNumericalResults([
{ value: shiftAverage, desc: "msec" },
{ value: paintAverage, desc: "paint count" },
]);
}
});

View File

@ -0,0 +1,38 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
function test() {
let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
Services.scriptloader.loadSubScript(testDir + "/perfhelpers.js", this);
requestLongerTimeout(5);
runTests();
}
gTests.push({
desc: "rotating divs",
run: function run() {
yield addTab(chromeRoot + "res/divs_test.html", true);
yield hideContextUI();
let stopwatch = new StopWatch();
let win = Browser.selectedTab.browser.contentWindow;
PerfTest.declareTest("B924F3FA-4CB5-4453-B131-53E3611E0765",
"rotating divs w/text", "graphics", "content",
"Measures animation frames for rotating translucent divs on top of a background of text.");
stopwatch.start();
// the test runs for ten seconds
let event = yield waitForEvent(win, "testfinished", 20000);
let msec = stopwatch.stop();
PerfTest.declareNumericalResult((event.detail.frames / msec) * 1000.0, "fps");
}
});

View File

@ -0,0 +1,163 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
function test() {
let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
Services.scriptloader.loadSubScript(testDir + "/perfhelpers.js", this);
requestLongerTimeout(5);
runTests();
}
function tapRadius() {
let dpi = Util.displayDPI;
return Services.prefs.getIntPref("ui.dragThresholdX") / 240 * dpi; // 27.999998728434246
}
gTests.push({
desc: "scrollBy",
run: function run() {
yield addTab(chromeRoot + "res/scroll_test.html");
yield hideContextUI();
let stopwatch = new StopWatch();
let win = Browser.selectedTab.browser.contentWindow;
PerfTest.declareTest("79235F74-037C-4F6B-AE47-FDCCC13458C3",
"scrollBy scroll", "graphics", "content",
"Measures performance of single line scrolls using scrollBy for a large page of text.");
let mozpaints = 0;
function onPaint() {
mozpaints++;
}
win.addEventListener("MozAfterPaint", onPaint, true);
let deferExit = Promise.defer();
function step() {
if (stopwatch.time() < 10000) {
win.scrollBy(0, 2);
// XXX slaves won't paint without this
win.mozRequestAnimationFrame(step);
return;
}
win.removeEventListener("MozAfterPaint", onPaint, true);
let msec = stopwatch.stop();
PerfTest.declareFrameRateResult(mozpaints, msec, "fps");
deferExit.resolve();
}
stopwatch.start();
win.mozRequestAnimationFrame(step);
yield deferExit.promise;
}
});
gTests.push({
desc: "scoll touch",
run: function run() {
yield addTab(chromeRoot + "res/scroll_test.html");
yield hideContextUI();
let stopwatch = new StopWatch();
let win = Browser.selectedTab.browser.contentWindow;
PerfTest.declareTest("14C693E5-3ED3-4A5D-93BC-A31F130A8CDE",
"touch scroll", "graphics", "content",
"Measures performance of single line scrolls using touch input for a large page of text.");
let y = win.innerHeight - 10;
EventUtils.synthesizeTouchAtPoint(100, y, { type: "touchstart" }, win);
EventUtils.synthesizeTouchAtPoint(100, y, { type: "touchmove" }, win);
y -= tapRadius() + 5;
EventUtils.synthesizeTouchAtPoint(100, y, { type: "touchmove" }, win);
let mozpaints = 0;
function onPaint() {
mozpaints++;
}
win.addEventListener("MozAfterPaint", onPaint, true);
let deferExit = Promise.defer();
function step() {
if (stopwatch.time() < 10000) {
y -= 2;
EventUtils.synthesizeTouchAtPoint(100, y, { type: "touchmove" }, win);
win.mozRequestAnimationFrame(step);
return;
}
win.removeEventListener("MozAfterPaint", onPaint, true);
let msec = stopwatch.stop();
EventUtils.synthesizeTouchAtPoint(100, y, { type: "touchend" }, win);
PerfTest.declareFrameRateResult(mozpaints, msec, "fps");
deferExit.resolve();
}
stopwatch.start();
win.mozRequestAnimationFrame(step);
yield deferExit.promise;
}
});
gTests.push({
desc: "canvas perf test",
run: function run() {
yield addTab(chromeRoot + "res/ripples.html");
let win = Browser.selectedTab.browser.contentWindow;
yield hideContextUI();
PerfTest.declareTest("6A455F96-2B2C-4B3C-B387-1AF2F1747CCF",
"ripples", "graphics", "canvas",
"Measures animation frames during a computationally " +
"heavy graphics demo using canvas.");
let stopwatch = new StopWatch(true);
let event = yield waitForEvent(win, "test", 20000);
let msec = stopwatch.stop();
PerfTest.declareFrameRateResult(event.detail.frames, msec, "fps");
}
});
gTests.push({
desc: "video perf test",
run: function run() {
yield addTab(chromeRoot + "res/tidevideo.html");
let win = Browser.selectedTab.browser.contentWindow;
let video = win.document.getElementById("videoelement");
video.pause();
yield hideContextUI();
yield waitForMs(1000);
PerfTest.declareTest("7F55F9C4-0ECF-4A13-9A9C-A38D46922C0B",
"video playback (moz paints)", "graphics", "video",
"Measures MozAfterPaints per second during five seconds of playback of an mp4.");
var paintCount = 0;
function onPaint() {
paintCount++;
}
let stopwatch = new StopWatch(true);
window.addEventListener("MozAfterPaint", onPaint, true);
video.play();
yield waitForMs(5000);
video.pause();
window.removeEventListener("MozAfterPaint", onPaint, true);
let msec = stopwatch.stop();
PerfTest.declareNumericalResult((paintCount / msec) * 1000.0, "pps");
PerfTest.declareTest("E132D333-4642-4597-B1F0-1E74B625DBD7",
"video playback (moz stats)", "graphics", "video",
"Report moz* related video performance stats during five seconds of playback of an mp4.");
let results = [];
results.push({ value: (video.mozDecodedFrames / msec) * 1000.0, desc: "mozDecodedFrames" });
results.push({ value: (video.mozParsedFrames / msec) * 1000.0, desc: "mozParsedFrames", shareAxis: 0 });
results.push({ value: (video.mozPresentedFrames / msec) * 1000.0, desc: "mozPresentedFrames", shareAxis: 0 });
results.push({ value: (video.mozPaintedFrames / msec) * 1000.0, desc: "mozPaintedFrames", shareAxis: 0 });
PerfTest.declareNumericalResults(results);
}
});

View File

@ -0,0 +1,146 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
function test() {
let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
Services.scriptloader.loadSubScript(testDir + "/perfhelpers.js", this);
runTests();
}
var EchoServer = {
_deferred: null,
_stopwatch: null,
_browser: null,
timeAsyncMessage: function timeAsyncMessage(aJson) {
if (this._stopwatch == null) {
this._stopwatch = new StopWatch(false);
}
this._deferred = Promise.defer();
messageManager.addMessageListener("Test:EchoResponse", this);
this._stopwatch.start();
this._browser.messageManager.sendAsyncMessage("Test:EchoRequest", aJson);
return this._deferred.promise;
},
receiveMessage: function receiveMessage(aMessage) {
let json = aMessage.json;
switch (aMessage.name) {
case "Test:EchoResponse":
let msec = this._stopwatch.stop();
messageManager.removeMessageListener("Test:EchoResponse", this);
this._deferred.resolve(msec);
break;
}
},
};
gTests.push({
desc: "msg manager 1",
run: function run() {
yield addTab("about:blank");
yield hideContextUI();
let browser = Browser.selectedTab.browser;
EchoServer._browser = browser;
browser.messageManager.loadFrameScript(chromeRoot + "msgmanagerecho.js", true);
yield waitForMs(1000);
let openDataSet = new Array();
for (let idx = 0; idx < 100; idx++) {
let msec = yield EchoServer.timeAsyncMessage({});
openDataSet.push(msec);
}
PerfTest.declareTest("A4354ACB-34DE-4796-914F-FD01EF298B1D",
"msg manager 01", "platform", "",
"Measures the time it takes to send/recv 100 message manager messages with an empty payload. " +
"Browser displays about:blank during the test.");
let result = PerfTest.computeAverage(openDataSet, { stripOutliers: false });
PerfTest.declareNumericalResult(result, "msec");
}
});
gTests.push({
desc: "msg manager 1",
run: function run() {
yield addTab("about:blank");
yield hideContextUI();
let browser = Browser.selectedTab.browser;
EchoServer._browser = browser;
browser.messageManager.loadFrameScript(chromeRoot + "msgmanagerecho.js", true);
let ds = {};
for (let i = 0; i < 100; i++) {
ds["i" + i] = { idx: i };
let table = ds["i" + i];
for (let j = 0; j < 100; j++) {
table["j" + i] = { rnd: Math.random() };
}
}
yield waitForMs(1000);
let openDataSet = new Array();
for (let idx = 0; idx < 100; idx++) {
let msec = yield EchoServer.timeAsyncMessage(ds);
openDataSet.push(msec);
}
PerfTest.declareTest("B4354ACB-34DE-4796-914F-FD01EF298B1D",
"msg manager 02", "platform", "",
"Measures the time it takes to send/recv 100 message manager messages with a heavy payload. " +
"Browser displays about:blank during the test.");
let result = PerfTest.computeAverage(openDataSet, { stripOutliers: false });
PerfTest.declareNumericalResult(result, "msec");
}
});
gTests.push({
desc: "msg manager 3",
run: function run() {
yield addTab(chromeRoot + "res/ripples.html");
yield hideContextUI();
let browser = Browser.selectedTab.browser;
EchoServer._browser = browser;
browser.messageManager.loadFrameScript(chromeRoot + "msgmanagerecho.js", true);
let ds = {};
for (let i = 0; i < 100; i++) {
ds["i" + i] = { idx: i };
let table = ds["i" + i];
for (let j = 0; j < 100; j++) {
table["j" + i] = { rnd: Math.random() };
}
}
yield waitForMs(1000);
let openDataSet = new Array();
for (let idx = 0; idx < 100; idx++) {
let msec = yield EchoServer.timeAsyncMessage(ds);
openDataSet.push(msec);
}
PerfTest.declareTest("C4354ACB-34DE-4796-914F-FD01EF298B1D",
"msg manager 03", "platform", "",
"Measures the time it takes to send/recv 100 message manager messages with a heavy payload. " +
"Browser displays ripples during the test.");
let result = PerfTest.computeAverage(openDataSet, { stripOutliers: false });
PerfTest.declareNumericalResult(result, "msec");
}
});

View File

@ -0,0 +1,46 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
function test() {
let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
Services.scriptloader.loadSubScript(testDir + "/perfhelpers.js", this);
runTests();
}
function timeTab(aUrl) {
return Task.spawn(function() {
let stopwatch = new StopWatch(true);
let tab = Browser.addTab(aUrl, true);
yield tab.pageShowPromise;
stopwatch.stop();
Browser.closeTab(tab)
yield waitForMs(500);
throw new Task.Result(stopwatch.time());
});
}
gTests.push({
desc: "tab open",
run: function run() {
yield addTab("about:blank");
yield hideContextUI();
yield waitForMs(5000);
let openDataSet = new Array();
for (let idx = 0; idx < 20; idx++) {
let time = yield timeTab("about:blank");
openDataSet.push(time);
}
PerfTest.declareTest("FBD7A532-D63A-44B5-9744-5CB07CFD131A",
"tab open", "browser", "ux",
"Open twenty tabs in succession, closing each before the next is opened. " +
"Gives the browser time to settle in between. Lets the ui react however it " +
"is designed to. Strips outliers.");
let result = PerfTest.computeAverage(openDataSet, { stripOutliers: true });
PerfTest.declareNumericalResult(result, "msec");
}
});

View File

@ -0,0 +1,4 @@
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

View File

@ -0,0 +1,26 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* TestEchoReceiver - receives json data, reserializes it and send it back.
*/
var TestEchoReceiver = {
init: function init() {
addMessageListener("Test:EchoRequest", this);
},
receiveMessage: function receiveMessage(aMessage) {
let json = aMessage.json;
switch (aMessage.name) {
case "Test:EchoRequest":
sendAsyncMessage("Test:EchoResponse", json);
break;
}
},
};
TestEchoReceiver.init();

View File

@ -28,7 +28,7 @@ var PerfTest = {
* Must be called by every test on startup. Graph server will
* search for result data between this declaration and the next.
*
* @param UID string for this particular test, case sensitive.
* @param aUUID string for this particular test, case sensitive.
* @param aName The name of the test.
* @param aCategory Top level test calegory. For example 'General',
* 'Graphics', 'Startup', 'Jim's Tests'.
@ -36,10 +36,10 @@ var PerfTest = {
* @param aDescription A detailed description (sentence or two) of
* what the test does.
*/
declareTest: function declareTest(aUID, aName, aCategory, aSubCategory, aDescription) {
this._uid = aUID;
declareTest: function declareTest(aUUID, aName, aCategory, aSubCategory, aDescription) {
this._uid = aUUID;
this._print(kDeclareId, this._toJsonStr({
id: aUID,
id: aUUID,
version: kDataSetVersion,
name: aName,
category: aCategory,
@ -225,9 +225,8 @@ StopWatch.prototype = {
},
/*
* Returns the total time ellapsed in milliseconds. If the stopwatch
* has not been stopped, stops it. Returns zero if no time has been
* accumulated.
* Returns the total time ellapsed in milliseconds. Returns zero if
* no time has been accumulated.
*/
time: function time() {
if (!this._userStartTime) {

View File

@ -5,5 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
TEST_DIRS += ['mochitest']
TEST_DIRS += ['mochiperf']
XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']