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
5bfa82fa
Commit
5bfa82fa
authored
Oct 09, 2019
by
Alexandra Rogova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up
parent
a9c6eac5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
66 deletions
+78
-66
load_index.js
load_index.js
+28
-23
load_index_random.js
load_index_random.js
+50
-43
No files found.
load_index.js
View file @
5bfa82fa
var
os
=
require
(
'
os
'
);
var
args
=
require
(
"
yargs
"
)
const
os
=
require
(
'
os
'
);
const
puppeteer
=
require
(
'
puppeteer
'
);
const
si
=
require
(
"
systeminformation
"
);
const
Server
=
require
(
'
ws
'
).
Server
;
const
args
=
require
(
"
yargs
"
)
.
usage
(
"
Usage : load_index.js -saveAs metadata/attachment -file file_path
"
)
.
demandOption
([
'
file
'
])
.
demandOption
([
'
saveAs
'
])
...
...
@@ -14,33 +17,35 @@ var args = require("yargs")
if
(
!
(
args
.
saveAs
===
"
metadata
"
||
args
.
saveAs
===
"
attachment
"
)){
throw
'
Unrecognized save as argument
'
;
}
var
saveAs
=
args
.
saveAs
;
const
puppeteer
=
require
(
'
puppeteer
'
);
var
browser
,
page
,
ramBefore
,
memBefore
;
const
si
=
require
(
"
systeminformation
"
);
var
saveAs
=
args
.
saveAs
,
browser
,
page
,
ramBefore
,
memBefore
;
var
Server
=
require
(
'
ws
'
).
Server
;
var
port
=
9030
;
var
ws
=
new
Server
({
port
:
port
});
ws
.
on
(
'
connection
'
,
function
(
w
){
w
.
on
(
'
message
'
,
function
(
msg
){
console
.
log
(
msg
);
var
ramAfter
=
(
os
.
totalmem
()
-
os
.
freemem
())
/
1024
/
1024
;
var
ramUsed
=
ramAfter
-
ramBefore
;
console
.
log
(
"
Ram used :
"
+
ramUsed
+
"
MB
"
);
si
.
mem
(
function
(
data
){
console
.
log
(
"
Memory used :
"
+
(
data
.
used
/
1024
/
1024
-
memBefore
)
+
"
MB
"
);
function
init_server
(){
var
port
=
9030
;
var
ws
=
new
Server
({
port
:
port
});
ws
.
on
(
'
connection
'
,
function
(
w
){
w
.
on
(
'
message
'
,
function
(
msg
){
console
.
log
(
msg
);
var
ramAfter
=
(
os
.
totalmem
()
-
os
.
freemem
())
/
1024
/
1024
;
var
ramUsed
=
ramAfter
-
ramBefore
;
console
.
log
(
"
Ram used :
"
+
ramUsed
+
"
MB
"
);
si
.
mem
(
function
(
data
){
console
.
log
(
"
Memory used :
"
+
(
data
.
used
/
1024
/
1024
-
memBefore
)
+
"
MB
"
);
});
browser
.
close
();
});
w
.
on
(
'
close
'
,
function
()
{
ws
.
close
();
});
browser
.
close
();
});
w
.
on
(
'
close
'
,
function
()
{
ws
.
close
();
});
}
);
}
(
async
()
=>
{
init_server
();
browser
=
await
puppeteer
.
launch
();
page
=
await
browser
.
newPage
();
ramBefore
=
(
os
.
totalmem
()
-
os
.
freemem
())
/
1024
/
1024
;
...
...
load_index_random.js
View file @
5bfa82fa
var
os
=
require
(
'
os
'
);
var
randomstring
=
require
(
"
randomstring
"
);
var
tmp
=
require
(
'
tmp
'
);
var
fs
=
require
(
'
fs
'
);
var
args
=
require
(
"
yargs
"
)
const
os
=
require
(
'
os
'
);
const
randomstring
=
require
(
"
randomstring
"
);
const
tmp
=
require
(
'
tmp
'
);
const
fs
=
require
(
'
fs
'
);
const
puppeteer
=
require
(
'
puppeteer
'
);
const
si
=
require
(
"
systeminformation
"
);
const
Server
=
require
(
'
ws
'
).
Server
;
const
args
=
require
(
"
yargs
"
)
.
usage
(
"
Usage : load_index.js -saveAs metadata/attachment -p Number of random paragraphs to generate
"
)
.
demandOption
([
'
saveAs
'
])
.
demandOption
([
'
paragraphs
'
])
...
...
@@ -14,14 +17,23 @@ var args = require("yargs")
.
nargs
(
"
paragraphs
"
,
1
)
.
argv
;
var
gen_rdm_string
=
function
(
length
){
if
(
!
(
args
.
saveAs
===
"
metadata
"
||
args
.
saveAs
===
"
attachment
"
)){
throw
'
Unrecognized save as argument
'
;
}
var
saveAs
=
args
.
saveAs
,
browser
,
page
,
ramBefore
,
memBefore
;
function
gen_rdm_string
(
length
){
return
randomstring
.
generate
({
length
:
length
,
charset
:
'
alphabetic
'
});
}
var
gen_rdm_sentence
=
function
(
word_count
,
word_length
){
function
gen_rdm_sentence
(
word_count
,
word_length
){
var
tmp_word_array
=
[];
for
(
var
i
=
0
;
i
<
word_count
;
i
+=
1
){
tmp_word_array
[
i
]
=
gen_rdm_string
(
word_length
);
...
...
@@ -29,7 +41,7 @@ var gen_rdm_sentence = function (word_count, word_length){
return
tmp_word_array
.
join
(
"
"
);
}
var
gen_rdm_paragraph
=
function
(
sentence_count
,
words_per_sentence
,
word_length
){
function
gen_rdm_paragraph
(
sentence_count
,
words_per_sentence
,
word_length
){
var
tmp_sentence_array
=
[];
for
(
var
i
=
0
;
i
<
sentence_count
;
i
+=
1
){
tmp_sentence_array
[
i
]
=
gen_rdm_sentence
(
words_per_sentence
,
word_length
);
...
...
@@ -37,54 +49,49 @@ var gen_rdm_paragraph = function (sentence_count, words_per_sentence, word_lengt
return
tmp_sentence_array
.
join
(
"
.
"
);
}
if
(
!
(
args
.
saveAs
===
"
metadata
"
||
args
.
saveAs
===
"
attachment
"
)){
throw
'
Unrecognized save as argument
'
;
}
var
saveAs
=
args
.
saveAs
;
const
puppeteer
=
require
(
'
puppeteer
'
);
var
browser
,
page
,
ramBefore
,
memBefore
;
const
si
=
require
(
"
systeminformation
"
);
var
Server
=
require
(
'
ws
'
).
Server
;
var
port
=
9030
;
var
ws
=
new
Server
({
port
:
port
});
ws
.
on
(
'
connection
'
,
function
(
w
){
w
.
on
(
'
message
'
,
function
(
msg
){
console
.
log
(
msg
);
var
ramAfter
=
(
os
.
totalmem
()
-
os
.
freemem
())
/
1024
/
1024
;
var
ramUsed
=
ramAfter
-
ramBefore
;
console
.
log
(
"
Ram used :
"
+
ramUsed
+
"
MB
"
);
si
.
mem
(
function
(
data
){
console
.
log
(
"
Memory used :
"
+
(
data
.
used
/
1024
/
1024
-
memBefore
)
+
"
MB
"
);
function
init_server
(){
var
port
=
9030
;
var
ws
=
new
Server
({
port
:
port
});
ws
.
on
(
'
connection
'
,
function
(
w
){
w
.
on
(
'
message
'
,
function
(
msg
){
console
.
log
(
msg
);
var
ramAfter
=
(
os
.
totalmem
()
-
os
.
freemem
())
/
1024
/
1024
;
var
ramUsed
=
ramAfter
-
ramBefore
;
console
.
log
(
"
Ram used :
"
+
ramUsed
+
"
MB
"
);
si
.
mem
(
function
(
data
){
console
.
log
(
"
Memory used :
"
+
(
data
.
used
/
1024
/
1024
-
memBefore
)
+
"
MB
"
);
});
browser
.
close
();
});
w
.
on
(
'
close
'
,
function
()
{
ws
.
close
();
});
browser
.
close
();
});
w
.
on
(
'
close
'
,
function
()
{
ws
.
close
();
});
});
(
async
()
=>
{
browser
=
await
puppeteer
.
launch
();
page
=
await
browser
.
newPage
();
ramBefore
=
(
os
.
totalmem
()
-
os
.
freemem
())
/
1024
/
1024
;
si
.
mem
(
function
(
data
){
memBefore
=
data
.
used
/
1024
/
1024
;
});
}
function
gen_random_content
(){
var
tmp_para_array
=
[];
for
(
var
i
=
0
;
i
<
args
.
p
;
i
+=
1
){
tmp_para_array
[
i
]
=
gen_rdm_paragraph
(
6
,
15
,
5
);
}
var
tmp_file
=
tmp
.
fileSync
();
fs
.
writeFileSync
(
tmp_file
.
name
,
tmp_para_array
.
join
(
"
\n
"
));
return
tmp_file
.
name
;
}
(
async
()
=>
{
init_server
();
var
file_path
=
gen_random_content
();
browser
=
await
puppeteer
.
launch
();
page
=
await
browser
.
newPage
();
ramBefore
=
(
os
.
totalmem
()
-
os
.
freemem
())
/
1024
/
1024
;
si
.
mem
(
function
(
data
){
memBefore
=
data
.
used
/
1024
/
1024
;
});
await
page
.
goto
(
'
https://softinst115787.host.vifib.net/public/unit_tests/index_load.html?saveAs=
'
+
saveAs
);
const
[
fileChooser
]
=
await
Promise
.
all
([
page
.
waitForFileChooser
(),
page
.
click
(
'
input#load
'
)
]);
await
fileChooser
.
accept
([
tmp_file
.
name
]);
await
fileChooser
.
accept
([
file_path
]);
})();
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