Commit feaa3ebe authored by Alexandra Rogova's avatar Alexandra Rogova

replaced process usage with puppeteer usage

parent 02450efe
const puppeteer = require('puppeteer');
var args = require("yargs")
.usage("Usage : load_index.js -saveAs metadata/attachment -file file_path")
.demandOption(['file'])
.demandOption(['saveAs'])
.alias("f", "file")
.alias("s", "saveAs")
.describe("file", "file containing content to put in the index, data must follow the CSV standard")
.describe("saveAs", "choose whether to save the index as metadata or attachments in the indexeddb")
.nargs("file", 1)
.nargs("saveAs", 1)
.argv;
.usage("Usage : load_index.js -saveAs metadata/attachment -file file_path")
.demandOption(['file'])
.demandOption(['saveAs'])
.alias("f", "file")
.alias("s", "saveAs")
.describe("file", "file containing content to put in the index, data must follow the CSV standard")
.describe("saveAs", "choose whether to save the index as metadata or attachments in the indexeddb")
.nargs("file", 1)
.nargs("saveAs", 1)
.argv;
if (!(args.saveAs === "metadata" ||args.saveAs === "attachment")){
throw 'Unrecognized save as argument';
}
var saveAs = args.saveAs;
var browser;
const puppeteer = require('puppeteer');
var browser, page;
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);
const used = process.memoryUsage();
for (let key in used) {
console.log(`${key} ${Math.round(used[key] / 1024 / 1024 * 100) / 100} MB`);
}
ws.on('connection', function(w){
w.on('message', function(msg){
console.log(msg);
page.metrics()
.then(function(values){
console.log(values.JSHeapUsedSize / 1024 / 1024);
si.mem(function(data){
console.log(data.used / 1024 / 1024);
});
browser.close();
});
w.on('close', function() {
ws.close();
});
});
});
w.on('close', function() {
ws.close();
});
});
(async () => {
const used = process.memoryUsage();
for (let key in used) {
console.log(`${key} ${Math.round(used[key] / 1024 / 1024 * 100) / 100} MB`);
}
browser = await puppeteer.launch();
const page = await browser.newPage();
page = await browser.newPage();
var metrics = await page.metrics();
console.log(metrics.JSHeapUsedSize / 1024 / 1024);
si.mem(function(data){
console.log(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(),
......
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