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
fd3bcd7f
Commit
fd3bcd7f
authored
Nov 19, 2019
by
Alexandra Rogova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added timed index export bench
parent
9338d893
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
0 deletions
+102
-0
export_index.js
export_index.js
+53
-0
export_index_bench.js
export_index_bench.js
+42
-0
results/export_index.csv
results/export_index.csv
+7
-0
No files found.
export_index.js
0 → 100644
View file @
fd3bcd7f
const
puppeteer
=
require
(
'
puppeteer
'
);
const
Server
=
require
(
'
ws
'
).
Server
;
const
args
=
require
(
"
yargs
"
)
.
usage
(
"
Usage : export_index.js -file file_path
"
)
.
demandOption
([
'
file
'
])
.
alias
(
"
f
"
,
"
file
"
)
.
describe
(
"
file
"
,
"
file containing content, data must follow JSON standard
"
)
.
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_index.html
'
);
const
[
fileChooser
]
=
await
Promise
.
all
([
page
.
waitForFileChooser
(),
page
.
click
(
'
input#load
'
)
]);
await
fileChooser
.
accept
([
args
.
file
]);
})();
export_index_bench.js
0 → 100644
View file @
fd3bcd7f
var
childProcess
=
require
(
'
child_process
'
);
const
fs
=
require
(
'
fs
'
);
var
stream
=
fs
.
createWriteStream
(
"
./results/export_index.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_index.csv
"
);
stream
.
write
(
"
items,zip,json
\n
"
);
var
to_run
=
[{
scriptPath
:
'
./export_index.js
'
,
args
:
[
'
-f
'
,
"
./test_files/INDEX/index100000.json
"
],
amount
:
100000
},
{
scriptPath
:
'
./export_index.js
'
,
args
:
[
'
-f
'
,
"
./test_files/INDEX/index50000.json
"
],
amount
:
50000
},
{
scriptPath
:
'
./export_index.js
'
,
args
:
[
'
-f
'
,
"
./test_files/INDEX/index10000.json
"
],
amount
:
10000
},
{
scriptPath
:
'
./export_index.js
'
,
args
:
[
'
-f
'
,
"
./test_files/INDEX/index5000.json
"
],
amount
:
5000
},
{
scriptPath
:
'
./export_index.js
'
,
args
:
[
'
-f
'
,
"
./test_files/INDEX/index1000.json
"
],
amount
:
1000
},
{
scriptPath
:
'
./export_index.js
'
,
args
:
[
'
-f
'
,
"
./test_files/INDEX/index100.json
"
],
amount
:
100
}];
runScriptSync
(
to_run
,
function
(
err
)
{
if
(
err
)
throw
err
;});
results/export_index.csv
0 → 100644
View file @
fd3bcd7f
items,zip,json
100,0,0
1000,0,0.026
5000,0,0.041
10000,0,0.05
50000,0,0.12
100000,0,1.092
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