Bug 1854072 - Change parallel marking threshold pref to use MB instead of KB r=sfink
[gecko.git] / testing / raptor / browsertime / speedometer3.js
blob48a06fcd1cb8ca7f6f2b6704d6c55b32cc9c59de
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /* eslint-env node */
7 module.exports = async function (context, commands) {
8   context.log.info("Starting Speedometer 3 test");
9   let url = context.options.browsertime.url;
10   let page_cycles = context.options.browsertime.page_cycles;
11   let speedometer_iterations =
12     context.options.browsertime.speedometer_iterations;
13   let page_cycle_delay = context.options.browsertime.page_cycle_delay;
14   let post_startup_delay = context.options.browsertime.post_startup_delay;
15   let page_timeout = context.options.timeouts.pageLoad;
16   let expose_profiler = context.options.browsertime.expose_profiler;
18   context.log.info(
19     "Waiting for %d ms (post_startup_delay)",
20     post_startup_delay
21   );
22   await commands.wait.byTime(post_startup_delay);
24   for (let count = 0; count < page_cycles; count++) {
25     context.log.info("Navigating to about:blank");
26     await commands.navigate("about:blank");
28     context.log.info("Cycle %d, waiting for %d ms", count, page_cycle_delay);
29     await commands.wait.byTime(page_cycle_delay);
31     context.log.info("Cycle %d, starting the measure", count);
32     if (expose_profiler === "true") {
33       context.log.info("Custom profiler start!");
34       await commands.profiler.start();
35     }
36     await commands.measure.start(url);
38     await commands.js.runAndWait(`
39         window.testDone = false;
40         window.suiteValues = [];
41         const benchmarkClient = {
42           didRunSuites(measuredValues) {
43             window.suiteValues.push(measuredValues);
44           },
45           didFinishLastIteration() {
46             window.testDone = true;
47           }
48         };
49         window.Suites.forEach((el) => {
50           el.disabled = false;
51         });
52         // BenchmarkRunner is overriden as the InteractiveBenchmarkRunner
53         const runner = new BenchmarkRunner(window.Suites, ${speedometer_iterations});
54         runner._client = benchmarkClient;
56         runner.runSuites();
57     `);
59     let data_exists = false;
60     let starttime = await commands.js.run(`return performance.now();`);
61     while (
62       !data_exists &&
63       (await commands.js.run(`return performance.now();`)) - starttime <
64         page_timeout
65     ) {
66       let wait_time = 3000;
67       context.log.info("Waiting %d ms for data from speedometer...", wait_time);
68       await commands.wait.byTime(wait_time);
69       data_exists = await commands.js.run("return window.testDone;");
70     }
71     if (expose_profiler === "true") {
72       context.log.info("Custom profiler stop!");
73       await commands.profiler.stop();
74     }
75     if (
76       !data_exists &&
77       (await commands.js.run(`return performance.now();`)) - starttime >=
78         page_timeout
79     ) {
80       context.log.error("Benchmark timed out. Aborting...");
81       return false;
82     }
83     let data = await commands.js.run(`return window.suiteValues;`);
84     context.log.info("Value of benchmark data: ", data);
86     commands.measure.addObject({ browsertime_benchmark: { s3: data } });
87   }
89   return true;