Commit 81feefc0 authored by Alexandra Rogova's avatar Alexandra Rogova

test

parent 12e3e025
items,ramUsed,memUsed
1000,-371.4140625,511.953125
2000,80.359375,61.76171875
3000,50.1640625,128.7734375
4000,159.91796875,28.36328125
1000,49.30078125,96.55078125
2000,178.94140625,-17.5
3000,106.48828125,80.24609375
4000,150.515625,10.12109375
5000,152.6015625,-4.84765625
6000,168.3515625,26.34765625
7000,108.5234375,25.72265625
8000,174.24609375,-28.44921875
9000,245.22265625,-110.80859375
10000,307.796875,-157.94140625
11000,292.6328125,89.296875
12000,268.45703125,-121.4921875
13000,172.484375,-6.5390625
14000,300.78515625,81.37109375
15000,293.015625,-167.6875
16000,355.36328125,-245.0390625
17000,254.93359375,-165.453125
18000,417.12890625,-296.078125
19000,416.07421875,51.3515625
20000,392.8828125,48.1640625
21000,207.35546875,-113.38671875
22000,322.1875,50.01171875
23000,487.609375,-274.7109375
24000,413.46875,100.234375
25000,616.59765625,-420.63671875
26000,480.8984375,59.05078125
27000,480.05078125,51.05078125
28000,514.12890625,74.0703125
29000,655.87890625,-542.4921875
30000,537.5859375,-460.06640625
items,ramUsed,memUsed
1000,1582.06640625,1582.35546875
2000,1564.01171875,1564.30078125
3000,1439.390625,1439.6796875
4000,1531.23046875,1531.51953125
5000,1511.859375,1512.1484375
6000,1520.8515625,1521.140625
7000,1506.20703125,1506.49609375
8000,1527.12890625,1527.41796875
9000,1517.73046875,1518.01953125
10000,1516.6875,1516.9765625
11000,1484.9453125,1485.234375
12000,1491.2109375,1491.5
13000,1499.46875,1499.7578125
14000,1482.703125,1482.9921875
15000,1481.7734375,1482.0625
16000,1489.4375,1489.7265625
17000,1446.17578125,1446.46484375
18000,1426.0234375,1426.3125
19000,1437.16015625,1437.44921875
20000,1431.12890625,1431.41796875
21000,1421.43359375,1421.72265625
22000,1427.8359375,1428.125
23000,1416.953125,1417.2421875
24000,1390.0625,1390.3515625
25000,1578.45703125,1578.74609375
26000,1586.296875,1586.5859375
27000,1576.359375,1576.6484375
28000,1566.72265625,1567.01171875
29000,1539.75390625,1540.04296875
30000,1564.5234375,1564.8125
31000,1542.69140625,1542.98046875
32000,1480.265625,1480.5546875
33000,1490.2734375,1490.5625
34000,1431.7421875,1432.03125
35000,1454.63671875,1454.92578125
36000,1419.01171875,1419.30078125
37000,1452.23046875,1452.51953125
38000,1417.296875,1417.5859375
39000,1434.09375,1434.3828125
40000,1388.97265625,1389.26171875
41000,1411.27734375,1411.56640625
42000,1401.07421875,1401.36328125
43000,1400.30078125,1400.58984375
44000,1387.65625,1387.9453125
45000,1405.26171875,1405.55078125
46000,1386.33203125,1386.62109375
47000,1379.6875,1379.9765625
48000,1326.859375,1327.1484375
49000,1358.4921875,1358.78125
50000,1363.62890625,1363.91796875
51000,1322.61328125,1322.90234375
52000,1384.33984375,1384.62890625
53000,1382.1015625,1382.390625
54000,1364.40234375,1364.69140625
55000,1339.6953125,1339.984375
56000,1344.0078125,1344.296875
57000,1330.73828125,1331.02734375
58000,1358.9609375,1359.25
59000,1353.61328125,1353.90234375
60000,1346.6953125,1346.984375
61000,1341.9609375,1342.25
62000,1332.21484375,1332.50390625
63000,1322.15234375,1322.44140625
64000,1328.78515625,1329.07421875
65000,1335.79296875,1336.08203125
66000,1337.7578125,1338.046875
67000,1332.21875,1332.5078125
68000,1343.05078125,1343.33984375
69000,1325.21875,1325.5078125
70000,1341.92578125,1342.21484375
71000,1319.7578125,1320.046875
72000,1325.3515625,1325.640625
73000,1307.82421875,1308.11328125
74000,1333.80859375,1334.08984375
75000,1343.4453125,1343.734375
76000,1309.26171875,1309.55078125
77000,1303.34765625,1303.63671875
78000,1345.3671875,1345.6328125
79000,1298.8359375,1299.125
80000,1281.39453125,1281.68359375
81000,1302.796875,1303.0859375
82000,1323.21484375,1323.50390625
83000,1314.2734375,1314.5625
84000,1335.68359375,1335.97265625
85000,1335.51953125,1335.80859375
86000,1261.93359375,1262.22265625
87000,1293.59765625,1293.88671875
88000,1311.0703125,1311.359375
89000,1281.2734375,1281.5625
90000,1288.6875,1288.9765625
91000,1274.71875,1275.0078125
92000,1320.37890625,1320.66796875
93000,1296.1171875,1296.40625
94000,1326.2421875,1326.53125
95000,1149.70703125,1149.99609375
96000,1268.26171875,1268.55078125
97000,1262.0390625,1262.328125
98000,1282.65625,1282.9453125
99000,1280.30859375,1280.59765625
100000,1301.03515625,1301.32421875
101000,1288.2109375,1288.5
102000,1259.11328125,1259.40234375
103000,1243.87109375,1244.16015625
104000,1271.59765625,1271.88671875
105000,1256.5390625,1256.828125
106000,1234.1796875,1234.46875
107000,1269.859375,1270.1484375
108000,1289.671875,1289.9609375
109000,1314.84375,1315.1328125
110000,1288.4140625,1288.703125
111000,1295.75390625,1296.04296875
112000,1287.62890625,1287.91796875
113000,777.83203125,778.12109375
114000,1248.07421875,1248.36328125
115000,1231.12109375,1231.41015625
116000,1253.17578125,1253.46484375
117000,1270.25390625,1270.54296875
118000,1265.3515625,1265.640625
119000,1263.6484375,1263.9375
120000,1277.91015625,1278.19921875
121000,1300.4296875,1300.71875
122000,1241.53515625,1241.82421875
123000,1232.37890625,1232.66796875
124000,1272.859375,1273.1484375
125000,1238.3359375,1238.625
126000,1271.875,1272.1640625
127000,1231.6484375,1231.9375
128000,1249.328125,1249.6171875
129000,1262.05859375,1262.34765625
130000,1254.47265625,1254.76171875
131000,1224.8984375,1225.1875
132000,1267.53515625,1267.82421875
133000,1234.6875,1234.9765625
134000,1249.1171875,1249.40625
135000,1241.3125,1241.6015625
136000,1261.98828125,1262.2734375
137000,1256.41015625,1256.69921875
138000,1259.07421875,1259.36328125
139000,1274.83984375,1275.12890625
140000,1195.36328125,1195.65234375
141000,1233.578125,1233.8671875
142000,1233.83984375,1234.125
143000,1212.77734375,1213.06640625
144000,1260.76171875,1261.05078125
145000,1233.94140625,1234.23046875
146000,1239.1796875,1239.46875
147000,1252.84375,1253.1328125
148000,1261.41796875,1261.70703125
149000,1252.45703125,1252.74609375
150000,1216.26171875,1216.55078125
151000,1179.19921875,1179.48828125
152000,1223.23046875,1223.515625
153000,1242.171875,1242.4609375
154000,1222.2421875,1222.53125
155000,1243.17578125,1243.46484375
156000,1278.734375,1279.0234375
157000,1222.9765625,1223.265625
158000,1254.0546875,1254.34375
159000,1248.38671875,1248.67578125
160000,1263.046875,1263.3359375
161000,1255.9453125,1256.234375
162000,1251.16015625,1251.44921875
163000,1293.0859375,1293.375
164000,1281.97265625,1282.26171875
165000,1270.02734375,1270.31640625
166000,1230.125,1230.4140625
167000,1261.2578125,1261.546875
168000,1247.015625,1247.3046875
169000,1277.2734375,1277.5625
170000,1267.39453125,1267.68359375
171000,1248.4453125,1248.734375
172000,1263.55078125,1263.83984375
173000,1282.75390625,1283.04296875
174000,1262.20703125,1262.49609375
175000,1269.55078125,1269.83984375
176000,1253.41015625,1253.69921875
177000,1271.8671875,1272.15625
178000,1252.86328125,1253.15234375
179000,1249.60546875,1249.89453125
180000,1237.16796875,1237.45703125
181000,1267.26171875,1267.55078125
182000,1256.625,1256.9140625
183000,1271.08203125,1271.37109375
184000,1240.375,1240.6640625
185000,1260.44140625,1260.73046875
186000,1241.36328125,1241.65234375
187000,1233.58984375,1233.87890625
188000,1247.48046875,1247.76953125
189000,1259.99609375,1260.28515625
190000,1207.9140625,1208.203125
191000,1256.68359375,1256.97265625
192000,1257.4140625,1257.703125
193000,1244.8515625,1245.140625
194000,1223.84765625,1224.13671875
195000,1253.91015625,1254.19921875
196000,1241.796875,1242.0859375
197000,1254.6015625,1254.890625
198000,1238.953125,1239.2421875
199000,1212.04296875,1212.33203125
200000,1198.65234375,1198.94140625
201000,1235.29296875,1235.58203125
202000,1240.72265625,1241.01171875
203000,1192.26953125,1192.55859375
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;
var stream = fs.createWriteStream("./results/test.csv", {flags:'a'});
const args = require("yargs")
.usage("Usage : load_content_random.js -saveAs metadata/attachment -p Number of random paragraphs to generate")
.demandOption(['saveAs'])
.demandOption(['paragraphs'])
.alias("p", "paragraphs")
.alias("s", "saveAs")
.describe("paragraphs", "Number of random paragraphs to generate")
.describe("saveAs", "Choose whether to save the content as metadata or attachments in the indexeddb")
.nargs("saveAs", 1)
.nargs("paragraphs", 1)
.argv;
if (!(args.saveAs === "metadata" ||args.saveAs === "attachment")){
throw 'Unrecognized save as argument';
}
var saveAs = args.saveAs,
browser,
page,
result,
n = 0,
time,
ramBefore,
memBefore;
function gen_rdm_string (length){
return randomstring.generate({
length: length,
charset: 'alphabetic'
});
}
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);
}
return tmp_word_array.join(" ");
}
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);
}
return tmp_sentence_array.join(". ");
}
function gen_random_content (){
var tmp_para_array = [];
result = [];
for(var i=0; i<args.p; i+=1){
tmp_para_array[i] = gen_rdm_paragraph(6, 15, 5);
}
for (var i=0; i<=args.p; i+=1000){
var tmp_file = tmp.fileSync();
fs.writeFileSync(tmp_file.name, tmp_para_array.slice(i, i+1000).join("\n"));
result.push(tmp_file.name);
}
return result;
}
function init_server (){
var port = 9030;
var ws = new Server({port: port});
ws.on('connection', function(w){
w.on('message', function(msg){
var ramAfter = (os.totalmem() - os.freemem()) / 1024 / 1024;
var ramUsed = ramAfter - ramBefore;
si.mem(function(data){
var memAfter = (data.used / 1024 / 1024 - memBefore);
stream.write(n + "," + -ramUsed + "," + -memAfter + "\n");
console.log(n + "," + -ramUsed + "," + -memAfter + "\n");
if (result.length === 0){
browser.close();
} else {
query();
}
});
});
w.on('close', function() {
ws.close();
});
});
}
function timeout (){ //Every 30 minutes, check if more than 2 hours have passed since last response
setTimeout(function () {
if (Date.now() - time > 7200000){ //2 hours
stream.write(n + ",Timeout error \n");
process.exit();
} else {
timeout();
}
}, 1800000); //30 minutes
}
async function query (){
n += 1000;
time = Date.now();
const [fileChooser] = await Promise.all([
page.waitForFileChooser(),
page.click('input#load')
]);
await fileChooser.accept([result.shift()]);
}
(async () => {
stream.write("items,ramUsed,memUsed\n");
init_server();
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/content_load.html?saveAs='+saveAs);
query();
})();
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