Commit 727f2a61 authored by 姚广胤's avatar 姚广胤

更改项目名称

parent e2b98a2b
{
"name": "warden",
"description": "an automate performance watcher",
"description": "an automate performance test tool",
"version": "1.0.0",
"author": "jsholic <junhe0723@gmail.com>",
"contributors": [
......
{
"name": "warden",
"description": "an automate performance watcher",
"description": "an automate performance test tool",
"version": "1.0.0",
"main": "app.js",
"scripts": {
......
......@@ -7,15 +7,19 @@ const iPhone = devices['iPhone 6'];
*
*/
const iterateTimes = async (task, n = 2) => {
console.info('iterateTimes start');
const allTaskResult = [];
for (let i = 0; i < n; i++) {
allTaskResult.push(await runBrowser(task));
}
console.info('iterateTimes end');
return await groupPage(allTaskResult, task);
};
const groupPage = async (allTaskResult, task) => {
console.info('groupPage start');
const taskCopy = JSON.parse(JSON.stringify(task));
allTaskResult.forEach(taskResult => {
......@@ -29,7 +33,7 @@ const groupPage = async (allTaskResult, task) => {
unitTaskCopy['arr'].push(page);
});
});
console.info('groupPage end');
return taskCopy;
};
......@@ -37,6 +41,7 @@ const groupPage = async (allTaskResult, task) => {
* 启用无头浏览器,根据任务里的页面地址去循环执行
*/
const runBrowser = async task => {
console.info('runBrowser start');
const browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
......@@ -48,6 +53,7 @@ const runBrowser = async task => {
browser.close();
console.info('runBrowser end');
return taskResult;
};
......@@ -58,9 +64,10 @@ const runBrowser = async task => {
* @param {*} unitTask
*/
const runPage = async (browser, unitTask) => {
console.info('runPage start');
try {
const page = await browser.newPage();
const { href, arr } = unitTask;
const { href } = unitTask;
await page.emulate(iPhone);
......@@ -72,6 +79,7 @@ const runPage = async (browser, unitTask) => {
await page.close();
console.info('runPage end');
return testResult;
} catch (err) {
throw err;
......@@ -85,6 +93,8 @@ const runPage = async (browser, unitTask) => {
* @param {*} unitTask
*/
const collectTiming = async page => {
console.info('collectTiming start');
return await page.evaluate(() => {
const pt = window.performance.timing;
......
{
"name": "warden",
"description": "an automate performance watcher",
"description": "an automate performance test tool",
"version": "1.0.0",
"author": "jsholic <junhe0723@gmail.com>",
"contributors": [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment