Commit cc5cce49 authored by Alexandra Rogova's avatar Alexandra Rogova

added timer to index export

parent 541a9b6f
const puppeteer = require('puppeteer');
const Server = require('ws').Server;
const args = require("yargs")
.usage("Usage : download_index.js -file file_path")
.demandOption(['file'])
......@@ -7,8 +8,33 @@ const args = require("yargs")
.nargs("file", 1)
.argv;
var browser,
start;
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 === "Done"){
var total = Date.now() - start;
console.log("Time spent : " + total/1000 + "s");
} else {
console.log("Error : " + msg);
browser.close();
}
});
w.on('close', function() {
ws.close();
});
});
}
(async () => {
var browser = await puppeteer.launch({headless: false});
init_server();
browser = await puppeteer.launch({headless: false});
var page = await browser.newPage();
await page.goto('https://softinst115787.host.vifib.net/public/unit_tests/download_index.html');
const [fileChooser] = await Promise.all([
......
const puppeteer = require('puppeteer');
const Server = require('ws').Server;
const randomstring = require("randomstring");
const tmp = require('tmp');
const fs = require('fs');
......@@ -10,6 +11,30 @@ const args = require("yargs")
.nargs("prom", 1)
.argv;
var browser,
start;
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 === "Done"){
var total = Date.now() - start;
console.log("Time spent : " + total/1000 + "s");
} else {
console.log("Error : " + msg);
browser.close();
}
});
w.on('close', function() {
ws.close();
});
});
}
function gen_rdm_string (length){
return randomstring.generate({
length: length,
......@@ -44,8 +69,9 @@ function gen_random_content (){
}
(async () => {
init_server();
var file_path = gen_random_content();
var browser = await puppeteer.launch({headless: false});
browser = await puppeteer.launch({headless: false});
var page = await browser.newPage();
await page.goto('https://softinst115787.host.vifib.net/public/unit_tests/download_index.html');
const [fileChooser] = await Promise.all([
......
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