Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
warden
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姚广胤
warden
Commits
727f2a61
Commit
727f2a61
authored
Mar 27, 2018
by
姚广胤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更改项目名称
parent
e2b98a2b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
5 deletions
+15
-5
package.json
package.json
+1
-1
package.json
server/package.json
+1
-1
timing.js
server/task/timing.js
+12
-2
package.json
web/package.json
+1
-1
No files found.
package.json
View file @
727f2a61
{
"name"
:
"warden"
,
"description"
:
"an automate performance
watcher
"
,
"description"
:
"an automate performance
test tool
"
,
"version"
:
"1.0.0"
,
"author"
:
"jsholic <junhe0723@gmail.com>"
,
"contributors"
:
[
...
...
server/package.json
View file @
727f2a61
{
"name"
:
"warden"
,
"description"
:
"an automate performance
watcher
"
,
"description"
:
"an automate performance
test tool
"
,
"version"
:
"1.0.0"
,
"main"
:
"app.js"
,
"scripts"
:
{
...
...
server/task/timing.js
View file @
727f2a61
...
...
@@ -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
;
...
...
web/package.json
View file @
727f2a61
{
"name"
:
"warden"
,
"description"
:
"an automate performance
watcher
"
,
"description"
:
"an automate performance
test tool
"
,
"version"
:
"1.0.0"
,
"author"
:
"jsholic <junhe0723@gmail.com>"
,
"contributors"
:
[
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment