1 Star 0 Fork 0

雷军/codesandbox-client

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
sandbox-performance-benchmark.js 862 Bytes
一键复制 编辑 原始数据 按行查看 历史
Ives van Hoorne 提交于 2018-05-23 19:28 +08:00 . Add benchmark
const puppeteer = require('puppeteer');
function pageLoaded(page) {
return new Promise(async resolve => {
await page.exposeFunction('__puppeteer__', () => {
if (resolve) {
resolve();
}
});
});
}
let browser = puppeteer.launch();
const SANDBOX_ID = process.argv[2];
const results = [];
(async function() {
browser = await browser;
console.log('Testing speed of ' + SANDBOX_ID);
for (let i = 0; i < (process.argv[3] || 10); i++) {
const page = await browser.newPage();
const waitFunction = pageLoaded(page);
page.goto('http://localhost:3002/#' + SANDBOX_ID);
const a = Date.now();
await waitFunction;
const d = Date.now() - a;
results.push(d);
console.log('Run #' + i + ': ' + d);
page.close();
}
console.log('Results', results.reduce((p, n) => p + n, 0) / results.length);
})();
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lei2jun/codesandbox-client.git
git@gitee.com:lei2jun/codesandbox-client.git
lei2jun
codesandbox-client
codesandbox-client
master

搜索帮助