Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Mynij-unit-tests
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Alexandra Rogova
Mynij-unit-tests
Commits
adb78155
Commit
adb78155
authored
Nov 19, 2019
by
Alexandra Rogova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added timed content export bench
parent
fd3bcd7f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
0 deletions
+98
-0
export_content.js
export_content.js
+53
-0
export_content_bench.js
export_content_bench.js
+40
-0
results/export_content.csv
results/export_content.csv
+5
-0
No files found.
export_content.js
0 → 100644
View file @
adb78155
const
puppeteer
=
require
(
'
puppeteer
'
);
const
Server
=
require
(
'
ws
'
).
Server
;
const
args
=
require
(
"
yargs
"
)
.
usage
(
"
Usage : export_content.js -file file_path
"
)
.
demandOption
([
'
file
'
])
.
alias
(
"
f
"
,
"
file
"
)
.
describe
(
"
file
"
,
"
file containing content, data must be ZIP
"
)
.
nargs
(
"
file
"
,
1
)
.
argv
;
var
browser
,
start
,
zip
,
plain_start
,
plain
;
function
init_server
(){
var
port
=
9030
;
var
ws
=
new
Server
({
port
:
port
});
ws
.
on
(
'
connection
'
,
function
(
w
){
w
.
on
(
'
message
'
,
function
(
msg
){
if
(
msg
===
"
Start
"
){
start
=
Date
.
now
();
}
else
if
(
msg
===
"
Zip
"
){
zip
=
Date
.
now
()
-
start
;
plain_start
=
Date
.
now
();
}
else
if
(
msg
===
"
JSON
"
){
plain
=
Date
.
now
()
-
plain_start
;
process
.
send
(
zip
/
1000
+
"
,
"
+
plain
/
1000
);
ws
.
close
();
browser
.
close
();
}
else
{
console
.
log
(
"
Error :
"
+
msg
);
browser
.
close
();
}
});
w
.
on
(
'
close
'
,
function
()
{
ws
.
close
();
});
});
}
(
async
()
=>
{
init_server
();
browser
=
await
puppeteer
.
launch
();
var
page
=
await
browser
.
newPage
();
await
page
.
goto
(
'
https://softinst115787.host.vifib.net/public/unit_tests/export_content.html
'
);
const
[
fileChooser
]
=
await
Promise
.
all
([
page
.
waitForFileChooser
(),
page
.
click
(
'
input#load
'
)
]);
await
fileChooser
.
accept
([
args
.
file
]);
})();
export_content_bench.js
0 → 100644
View file @
adb78155
var
childProcess
=
require
(
'
child_process
'
);
const
fs
=
require
(
'
fs
'
);
var
stream
=
fs
.
createWriteStream
(
"
./results/export_content.csv
"
,
{
flags
:
'
a
'
});
function
writeResult
(
items
,
info
){
stream
.
write
(
items
+
"
,
"
+
info
+
"
\n
"
);
}
function
runScriptSync
(
list
,
callback
)
{
if
(
list
.
length
===
0
)
return
;
var
invoked
=
false
,
to_run
=
list
.
pop
();
process
=
childProcess
.
fork
(
to_run
.
scriptPath
,
to_run
.
args
);
process
.
on
(
'
message
'
,
function
(
mes
){
console
.
log
(
to_run
.
amount
+
"
:
"
+
mes
)
writeResult
(
to_run
.
amount
,
mes
);
runScriptSync
(
list
,
callback
);
});
process
.
on
(
'
error
'
,
function
(
err
)
{
if
(
invoked
)
return
;
invoked
=
true
;
callback
(
err
);
});
process
.
on
(
'
exit
'
,
function
(
code
)
{
if
(
invoked
)
return
;
invoked
=
true
;
var
err
=
code
===
0
?
null
:
new
Error
(
'
exit code
'
+
code
);
callback
(
err
);
});
}
fs
.
truncateSync
(
"
./results/export_content.csv
"
);
stream
.
write
(
"
items,zip,json
\n
"
);
var
to_run
=
[{
scriptPath
:
'
./export_content.js
'
,
args
:
[
'
-f
'
,
"
./test_files/CONTENT/content100000.zip
"
],
amount
:
100000
},
{
scriptPath
:
'
./export_content.js
'
,
args
:
[
'
-f
'
,
"
./test_files/CONTENT/content10000.zip
"
],
amount
:
10000
},
{
scriptPath
:
'
./export_content.js
'
,
args
:
[
'
-f
'
,
"
./test_files/CONTENT/content1000.zip
"
],
amount
:
1000
},
{
scriptPath
:
'
./export_content.js
'
,
args
:
[
'
-f
'
,
"
./test_files/CONTENT/content100.zip
"
],
amount
:
100
}];
runScriptSync
(
to_run
,
function
(
err
)
{
if
(
err
)
throw
err
;});
results/export_content.csv
0 → 100644
View file @
adb78155
items,zip,json
100,0.016,0.01
1000,0.063,0.028
10000,0.699,0.029
100000,9.51,0.023
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