browsertime_tp6_bench.js (1134B)
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/. */ 4 5 /* eslint-env node */ 6 7 const { logTest } = require("./utils/profiling"); 8 9 module.exports = logTest( 10 "browsertime pageload benchmark", 11 async function (context, commands) { 12 let urlstr = context.options.browsertime.url; 13 const parsedUrls = urlstr.split(","); 14 15 let startTime = await commands.js.run( 16 `return performance.timeOrigin + performance.now();` 17 ); 18 for (let count = 0; count < parsedUrls.length; count++) { 19 context.log.info("Navigating to url:" + parsedUrls[count]); 20 context.log.info("Cycle %d, starting the measure", count); 21 await commands.measure.start(parsedUrls[count]); 22 } 23 24 let endTime = await commands.js.run( 25 `return performance.timeOrigin + performance.now();` 26 ); 27 28 context.log.info("Browsertime pageload benchmark ended."); 29 await commands.measure.add("pageload-benchmark", { 30 totalTime: endTime - startTime, 31 }); 32 return true; 33 } 34 );