Alexei Filippov | ff3b514 | 2018-05-24 03:13:55 +0900 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // To benchmark a specific version of Chrome set the CHROME_PATH environment |
| 6 | // variable, e.g.: |
Alexei Filippov | 80d11ff | 2018-07-04 11:08:38 +0900 | [diff] [blame] | 7 | // $ CHROME_PATH=~/chromium/src/out/Release/chrome node benchmark-octane.js |
Alexei Filippov | ff3b514 | 2018-05-24 03:13:55 +0900 | [diff] [blame] | 8 | |
| 9 | const puppeteer = require('puppeteer'); |
| 10 | |
Alexei Filippov | ff3b514 | 2018-05-24 03:13:55 +0900 | [diff] [blame] | 11 | async function runOctane(samplingRate) { |
| 12 | const args = ['--enable-devtools-experiments']; |
| 13 | if (samplingRate) |
| 14 | args.push(`--sampling-heap-profiler=${samplingRate}`); |
Alexei Filippov | 80d11ff | 2018-07-04 11:08:38 +0900 | [diff] [blame] | 15 | while (true) { |
| 16 | let brower; |
| 17 | try { |
| 18 | browser = await puppeteer.launch({ |
| 19 | executablePath: process.env.CHROME_PATH, args, headless: true}); |
| 20 | const page = await browser.newPage(); |
| 21 | await page.goto('https://chromium.github.io/octane/'); |
| 22 | await page.waitForSelector('#run-octane'); // Just in case. |
| 23 | await page.click('#run-octane'); |
Alexei Filippov | ff3b514 | 2018-05-24 03:13:55 +0900 | [diff] [blame] | 24 | |
Alexei Filippov | 80d11ff | 2018-07-04 11:08:38 +0900 | [diff] [blame] | 25 | const scoreDiv = await page.waitForSelector('#main-banner:only-child', |
| 26 | {timeout: 120000}); |
| 27 | const scoreText = await page.evaluate(e => e.innerText, scoreDiv); |
| 28 | const match = /Score:\s*(\d+)/.exec(scoreText); |
| 29 | if (match.length < 2) |
| 30 | continue; |
| 31 | return parseInt(match[1]); |
| 32 | } finally { |
| 33 | if (browser) |
| 34 | await browser.close(); |
Alexei Filippov | ff3b514 | 2018-05-24 03:13:55 +0900 | [diff] [blame] | 35 | } |
Alexei Filippov | ff3b514 | 2018-05-24 03:13:55 +0900 | [diff] [blame] | 36 | } |
| 37 | } |
| 38 | |
Alexei Filippov | 80d11ff | 2018-07-04 11:08:38 +0900 | [diff] [blame] | 39 | async function makeRuns(rates) { |
| 40 | const scores = []; |
| 41 | for (const rate of rates) |
| 42 | scores.push(await runOctane(rate)); |
| 43 | console.log(scores.join('\t')); |
Alexei Filippov | ff3b514 | 2018-05-24 03:13:55 +0900 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | async function main() { |
| 47 | console.log(`Using ${process.env.CHROME_PATH || puppeteer.executablePath()}`); |
Alexei Filippov | 80d11ff | 2018-07-04 11:08:38 +0900 | [diff] [blame] | 48 | const rates = [0]; |
| 49 | for (let rate = 8; rate <= 2048; rate *= 2) |
| 50 | rates.push(rate); |
| 51 | console.log('Rates [KB]:'); |
| 52 | console.log(rates.join('\t')); |
| 53 | console.log('='.repeat(rates.length * 8)); |
| 54 | for (let i = 0; i < 100; ++i) |
| 55 | await makeRuns(rates); |
Alexei Filippov | ff3b514 | 2018-05-24 03:13:55 +0900 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | main(); |