browser/metro/base/tests/mochiperf/browser_miscgfx_01.js

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 "use strict";
michael@0 5
michael@0 6 function test() {
michael@0 7 requestLongerTimeout(2);
michael@0 8 runTests();
michael@0 9 }
michael@0 10
michael@0 11 function tapRadius() {
michael@0 12 let dpi = Util.displayDPI;
michael@0 13 return Services.prefs.getIntPref("ui.dragThresholdX") / 240 * dpi; // 27.999998728434246
michael@0 14 }
michael@0 15
michael@0 16 gTests.push({
michael@0 17 desc: "scrollBy",
michael@0 18 run: function run() {
michael@0 19 yield addTab(chromeRoot + "res/scroll_test.html");
michael@0 20 yield hideContextUI();
michael@0 21 yield hideNavBar();
michael@0 22
michael@0 23 let stopwatch = new StopWatch();
michael@0 24 let win = Browser.selectedTab.browser.contentWindow;
michael@0 25 let domUtils = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
michael@0 26 let deferExit = Promise.defer();
michael@0 27 let recordingHandle = domUtils.startFrameTimeRecording();
michael@0 28
michael@0 29 function step() {
michael@0 30 if (stopwatch.time() < 5000) {
michael@0 31 win.scrollBy(0, 2);
michael@0 32 win.mozRequestAnimationFrame(step);
michael@0 33 return;
michael@0 34 }
michael@0 35
michael@0 36 let intervals = domUtils.stopFrameTimeRecording(recordingHandle);
michael@0 37 let msec = stopwatch.stop();
michael@0 38 PerfTest.declareTest("79235F74-037C-4F6B-AE47-FDCCC13458C3",
michael@0 39 "scrollBy scroll", "graphics", "content",
michael@0 40 "Measures performance of single line scrolls for a large page of text using FTR.");
michael@0 41 PerfTest.declareFrameRateResult(intervals.length, msec, "fps");
michael@0 42 deferExit.resolve();
michael@0 43 }
michael@0 44
michael@0 45 stopwatch.start();
michael@0 46 win.mozRequestAnimationFrame(step);
michael@0 47 yield deferExit.promise;
michael@0 48 }
michael@0 49 });
michael@0 50
michael@0 51 gTests.push({
michael@0 52 desc: "canvas perf test",
michael@0 53 run: function run() {
michael@0 54 yield addTab(chromeRoot + "res/ripples.html");
michael@0 55 yield hideContextUI();
michael@0 56 yield hideNavBar();
michael@0 57
michael@0 58 let win = Browser.selectedTab.browser.contentWindow;
michael@0 59 let domUtils = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
michael@0 60 let recordingHandle = domUtils.startFrameTimeRecording();
michael@0 61 PerfTest.declareTest("6A455F96-2B2C-4B3C-B387-1AF2F1747CCF",
michael@0 62 "ripples", "graphics", "canvas",
michael@0 63 "Measures animation frames during a computationally " +
michael@0 64 "heavy graphics demo using canvas using FTR.");
michael@0 65 let stopwatch = new StopWatch(true);
michael@0 66 // test page runs for 5 seconds
michael@0 67 let event = yield waitForEvent(win, "test", 10000);
michael@0 68 let intervals = domUtils.stopFrameTimeRecording(recordingHandle);
michael@0 69 let msec = stopwatch.stop();
michael@0 70 PerfTest.declareFrameRateResult(intervals.length, msec, "fps");
michael@0 71 }
michael@0 72 });
michael@0 73
michael@0 74 gTests.push({
michael@0 75 desc: "video perf test",
michael@0 76 run: function run() {
michael@0 77 yield addTab(chromeRoot + "res/tidevideo.html");
michael@0 78 let win = Browser.selectedTab.browser.contentWindow;
michael@0 79 let domUtils = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
michael@0 80 let video = win.document.getElementById("videoelement");
michael@0 81 video.pause();
michael@0 82 yield hideContextUI();
michael@0 83 yield hideNavBar();
michael@0 84 yield waitForMs(1000);
michael@0 85 PerfTest.declareTest("7F55F9C4-0ECF-4A13-9A9C-A38D46922C0B",
michael@0 86 "video playback (moz paints)", "graphics", "video",
michael@0 87 "Measures frames per second during five seconds of playback of an mp4.");
michael@0 88
michael@0 89 let recordingHandle = domUtils.startFrameTimeRecording();
michael@0 90 let stopwatch = new StopWatch(true);
michael@0 91 video.play();
michael@0 92 yield waitForMs(5000);
michael@0 93 video.pause();
michael@0 94 let intervals = domUtils.stopFrameTimeRecording(recordingHandle);
michael@0 95 let msec = stopwatch.stop();
michael@0 96 PerfTest.declareFrameRateResult(intervals.length, msec, "fps");
michael@0 97
michael@0 98 PerfTest.declareTest("E132D333-4642-4597-B1F0-1E74B625DBD7",
michael@0 99 "video playback (moz stats)", "graphics", "video",
michael@0 100 "Report moz* related video performance stats during five seconds of playback of an mp4.");
michael@0 101 let results = [];
michael@0 102 results.push({ value: (video.mozDecodedFrames / msec) * 1000.0, desc: "mozDecodedFrames" });
michael@0 103 results.push({ value: (video.mozParsedFrames / msec) * 1000.0, desc: "mozParsedFrames", shareAxis: 0 });
michael@0 104 results.push({ value: (video.mozPresentedFrames / msec) * 1000.0, desc: "mozPresentedFrames", shareAxis: 0 });
michael@0 105 results.push({ value: (video.mozPaintedFrames / msec) * 1000.0, desc: "mozPaintedFrames", shareAxis: 0 });
michael@0 106 PerfTest.declareNumericalResults(results);
michael@0 107 }
michael@0 108 });

mercurial