Commit 66c04430 authored by Alexandra Rogova's avatar Alexandra Rogova

started auto bench scripts

parent cc5cce49
const puppeteer = require('puppeteer');
const getPort = require('get-port');
const Server = require('ws').Server;
const args = require("yargs")
.usage("Usage : add_rss.js -file file_path")
......@@ -12,10 +13,10 @@ var browser,
index_start,
index_total,
db_start,
db_total;
db_total,
port;
function init_server (){
var port = 9030;
var ws = new Server({port: port});
ws.on('connection', function(w){
w.on('message', function(msg){
......@@ -26,8 +27,9 @@ function init_server (){
db_start = Date.now();
} else if (msg.includes("Done")){
db_total = Date.now() - db_start;
console.log(msg + " in " + (db_total+index_total)/1000 +
"s (index : " + index_total/1000 + "s, db : " + db_total/1000 + "s)");
process.send((db_total+index_total)/1000);
// console.log(msg + " in " + (db_total+index_total)/1000 +
// "s (index : " + index_total/1000 + "s, db : " + db_total/1000 + "s)");
ws.close();
browser.close();
} else {
......@@ -43,10 +45,11 @@ function init_server (){
}
(async () => {
port = await getPort();
init_server();
browser = await puppeteer.launch();
var page = await browser.newPage();
await page.goto('https://softinst115787.host.vifib.net/public/unit_tests/add_rss.html');
await page.goto('https://softinst115787.host.vifib.net/public/unit_tests/add_rss.html?port='+port);
const [fileChooser] = await Promise.all([
page.waitForFileChooser(),
page.click('input#load')
......
......@@ -17,7 +17,8 @@ function init_server (){
ws.on('connection', function(w){
w.on('message', function(msg){
if (msg.includes("Done")){
var now = Date.now()
var now = Date.now();
process.send((now-start)/1000);
console.log(msg + " in " + (now-start)/1000 +"s");
ws.close();
browser.close();
......
/// <reference types="node"/>
import {Omit} from 'type-fest';
import {ListenOptions} from 'net';
declare namespace getPort {
interface Options extends Omit<ListenOptions, 'port'> {
/**
A preferred port or an iterable of preferred ports to use.
*/
readonly port?: number | Iterable<number>;
/**
The host on which port resolution should be performed. Can be either an IPv4 or IPv6 address.
*/
readonly host?: string;
}
}
declare const getPort: {
/**
Get an available TCP port number.
@returns Port number.
@example
```
import getPort = require('get-port');
(async () => {
console.log(await getPort());
//=> 51402
// Pass in a preferred port
console.log(await getPort({port: 3000}));
// Will use 3000 if available, otherwise fall back to a random port
// Pass in an array of preferred ports
console.log(await getPort({port: [3000, 3001, 3002]}));
// Will use any element in the preferred ports array if available, otherwise fall back to a random port
})();
```
*/
(options?: getPort.Options): Promise<number>;
/**
Make a range of ports `from`...`to`.
@param from - First port of the range. Must be in the range `1024`...`65535`.
@param to - Last port of the range. Must be in the range `1024`...`65535` and must be greater than `from`.
@returns The ports in the range.
@example
```
import getPort = require('get-port');
(async () => {
console.log(await getPort({port: getPort.makeRange(3000, 3100)}));
// Will use any port from 3000 to 3100, otherwise fall back to a random port
})();
```
*/
makeRange(from: number, to: number): Iterable<number>;
};
export = getPort;
'use strict';
const net = require('net');
const getAvailablePort = options => new Promise((resolve, reject) => {
const server = net.createServer();
server.unref();
server.on('error', reject);
server.listen(options, () => {
const {port} = server.address();
server.close(() => {
resolve(port);
});
});
});
const portCheckSequence = function * (ports) {
if (ports) {
yield * ports;
}
yield 0; // Fall back to 0 if anything else failed
};
module.exports = async options => {
let ports = null;
if (options) {
ports = typeof options.port === 'number' ? [options.port] : options.port;
}
for (const port of portCheckSequence(ports)) {
try {
return await getAvailablePort({...options, port}); // eslint-disable-line no-await-in-loop
} catch (error) {
if (error.code !== 'EADDRINUSE') {
throw error;
}
}
}
throw new Error('No available ports found');
};
module.exports.makeRange = (from, to) => {
if (!Number.isInteger(from) || !Number.isInteger(to)) {
throw new TypeError('`from` and `to` must be integer numbers');
}
if (from < 1024 || from > 65535) {
throw new RangeError('`from` must be between 1024 and 65535');
}
if (to < 1024 || to > 65536) {
throw new RangeError('`to` must be between 1024 and 65536');
}
if (to < from) {
throw new RangeError('`to` must be greater than or equal to `from`');
}
const generator = function * (from, to) {
for (let port = from; port <= to; port++) {
yield port;
}
};
return generator(from, to);
};
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
{
"_from": "get-port",
"_id": "get-port@5.0.0",
"_inBundle": false,
"_integrity": "sha512-imzMU0FjsZqNa6BqOjbbW6w5BivHIuQKopjpPqcnx0AVHJQKCxK1O+Ab3OrVXhrekqfVMjwA9ZYu062R+KcIsQ==",
"_location": "/get-port",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "get-port",
"name": "get-port",
"escapedName": "get-port",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/get-port/-/get-port-5.0.0.tgz",
"_shasum": "aa22b6b86fd926dd7884de3e23332c9f70c031a6",
"_spec": "get-port",
"_where": "C:\\Users\\thequ\\Documents\\Mynij\\Mynij-unit-tests",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/get-port/issues"
},
"bundleDependencies": false,
"dependencies": {
"type-fest": "^0.3.0"
},
"deprecated": false,
"description": "Get an available port",
"devDependencies": {
"@types/node": "^11.13.0",
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
},
"engines": {
"node": ">=8"
},
"files": [
"index.js",
"index.d.ts"
],
"homepage": "https://github.com/sindresorhus/get-port#readme",
"keywords": [
"port",
"find",
"finder",
"portfinder",
"free",
"available",
"connection",
"connect",
"open",
"net",
"tcp",
"scan",
"random",
"preferred",
"chosen"
],
"license": "MIT",
"name": "get-port",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/get-port.git"
},
"scripts": {
"test": "xo && ava && tsd"
},
"version": "5.0.0"
}
# get-port [![Build Status](https://travis-ci.org/sindresorhus/get-port.svg?branch=master)](https://travis-ci.org/sindresorhus/get-port)
> Get an available [TCP port](https://en.wikipedia.org/wiki/Port_(computer_networking))
## Install
```
$ npm install get-port
```
## Usage
```js
const getPort = require('get-port');
(async () => {
console.log(await getPort());
//=> 51402
})();
```
Pass in a preferred port:
```js
(async () => {
console.log(await getPort({port: 3000}));
// Will use 3000 if available, otherwise fall back to a random port
})();
```
Pass in an array of preferred ports:
```js
(async () => {
console.log(await getPort({port: [3000, 3001, 3002]}));
// Will use any element in the preferred ports array if available, otherwise fall back to a random port
})();
```
Use the `makeRange()` helper in case you need a port in a certain range:
```js
(async () => {
console.log(await getPort({port: getPort.makeRange(3000, 3100)}));
// Will use any port from 3000 to 3100, otherwise fall back to a random port
})();
```
## API
### getPort([options])
Returns a `Promise` for a port number.
#### options
Type: `Object`
##### port
Type: `number | Iterable<number>`
A preferred port or an iterable of preferred ports to use.
##### host
Type: `string`
The host on which port resolution should be performed. Can be either an IPv4 or IPv6 address.
### getPort.makeRange(from, to)
Make a range of ports `from`...`to`.
Returns an `Iterable` for ports in the given range.
#### from
Type: `number`
First port of the range. Must be in the range `1024`...`65535`.
#### to
Type: `number`
Last port of the range. Must be in the range `1024`...`65535` and must be greater than `from`.
## Beware
There is a very tiny chance of a race condition if another service starts using the same port number as you in between the time you get the port number and you actually start using it.
## Related
- [get-port-cli](https://github.com/sindresorhus/get-port-cli) - CLI for this module
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)
......@@ -30,6 +30,12 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 4.14.17 | 2019-10-22 | `graphics()` improved display detection (windows) |
| 4.14.16 | 2019-10-19 | `graphics()` improved display detection (windows) |
| 4.14.15 | 2019-10-18 | `graphics()` fallback display detection (windows) |
| 4.14.14 | 2019-10-18 | `powerShell()` fixed error handling (windows) |
| 4.14.13 | 2019-10-15 | `networkConnections()` fixed parsing (linux) |
| 4.14.12 | 2019-10-14 | `getCpu()` fixed multi socket detection (linux) |
| 4.14.11 | 2019-10-01 | type definitions fix dockerInfo |
| 4.14.10 | 2019-10-01 | type definitions fix memLayout |
| 4.14.9 | 2019-10-01 | `processLoad()` fix windows |
......
......@@ -29,7 +29,7 @@
[![Caretaker][caretaker-image]][caretaker-url]
[![MIT license][license-img]][license-url]
**2019-03-12** - 5th birthday of systeminformation. This is amazing. Started as a small projekt just for myself, it now has > 8,000 lines of code, > 200 versions published, up to 100,000 downloads per month, > 1 Mio downloads overall. Thank you to all who contributed to this project!
This is amazing. Started as a small project just for myself, it now has > 9,000 lines of code, > 250 versions published, up to 400,000 downloads per month, > 1 Mio downloads overall. Thank you to all who contributed to this project!
## New Version 4.0
......
......@@ -321,38 +321,21 @@ function getCpu() {
result.cache.l3 = util.getValue(lines, 'l3 cache');
if (result.cache.l3) { result.cache.l3 = parseInt(result.cache.l3) * (result.cache.l3.indexOf('K') !== -1 ? 1024 : 1); }
const threadsPerCore = util.getValue(lines, 'thread(s) per core') || '1';
const processors = util.getValue(lines, 'socket(s)') || '1';
let threadsPerCoreInt = parseInt(threadsPerCore, 10);
let processorsInt = parseInt(processors, 10);
result.physicalCores = result.cores / threadsPerCoreInt;
result.processors = processorsInt;
// socket type
lines = [];
let lines2 = [];
exec('export LC_ALL=C; dmidecode –t 4 2>/dev/null | grep "Upgrade: Socket"; unset LC_ALL', function (error2, stdout2) {
lines = stdout2.toString().split('\n');
if (lines && lines.length) {
result.socket = util.getValue(lines, 'Upgrade').replace('Socket', '').trim();
lines2 = stdout2.toString().split('\n');
if (lines2 && lines2.length) {
result.socket = util.getValue(lines2, 'Upgrade').replace('Socket', '').trim();
}
// # processurs & # threads/core - method 1
let threadsPerCoreInt = 0;
lines = [];
exec('cat /proc/cpuinfo | grep -E "physical id|core id"', function (error2, stdout3) {
lines = stdout3.toString().split('\n');
if (lines && lines.length) {
result.processors = util.countUniqueLines(lines, 'physical id') || 1;
result.physicalCores = util.countUniqueLines(lines, 'core id') / result.processors;
if (result.physicalCores) {
threadsPerCoreInt = result.cores / result.physicalCores;
}
}
// # threads/core - method 2
if (threadsPerCoreInt === 0) {
const threadsPerCore = util.getValue(lines, 'thread(s) per core');
if (threadsPerCore) {
threadsPerCoreInt = parseInt(threadsPerCore, 10);
if (!isNaN(threadsPerCoreInt)) {
result.physicalCores = result.cores / threadsPerCoreInt;
}
}
}
resolve(result);
});
resolve(result);
});
});
}
......
......@@ -561,6 +561,7 @@ function graphics(callback) {
workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorBasicDisplayParams | fl'));
workload.push(util.powerShell('Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Screen]::AllScreens'));
workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorConnectionParams | fl'));
workload.push(util.powerShell('gwmi WmiMonitorID -Namespace root\\wmi | ForEach-Object {(($_.ManufacturerName -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.ProductCodeID -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.UserFriendlyName -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.SerialNumberID -notmatch 0 | foreach {[char]$_}) -join "") + "|" + $_.InstanceName}'));
Promise.all(
workload
......@@ -587,19 +588,34 @@ function graphics(callback) {
let tsections = data[4].split(/\n\s*\n/);
tsections.shift();
result.displays = parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections);
// monitor ID (powershell) - model / vendor
const res = data[5].split(/\r\n/);
let isections = [];
res.forEach(element => {
const parts = element.split('|');
if (parts.length === 5) {
isections.push({
vendor: parts[0],
code: parts[1],
model: parts[2],
serial: parts[3],
instanceId: parts[4]
});
}
});
result.displays = parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections, isections);
if (result.controllers.length === 1 && result.displays.length === 1) {
if (result.displays.length === 1) {
if (_resolutionx) {
result.displays[0].currentResX = _resolutionx;
if (!result.displays[0].resolutionx) {
result.displays[0].resolutionx = _resolutionx;
result.displays[0].resolutionx = _resolutionx;
if (!result.displays[0].currentResX) {
result.displays[0].currentResX = _resolutionx;
}
}
if (_resolutiony) {
result.displays[0].currentResY = _resolutiony;
if (result.displays[0].resolutiony === 0) {
result.displays[0].resolutiony = _resolutiony;
result.displays[0].resolutiony = _resolutiony;
if (result.displays[0].currentResY === 0) {
result.displays[0].currentResY = _resolutiony;
}
}
if (_pixeldepth) {
......@@ -643,10 +659,10 @@ function graphics(callback) {
vram: parseInt(util.getValue(lines, 'AdapterRAM', '='), 10) / 1024 / 1024,
vramDynamic: (util.getValue(lines, 'VideoMemoryType', '=') === '2')
});
_resolutionx = util.toInt(util.getValue(lines, 'CurrentHorizontalResolution', '='));
_resolutiony = util.toInt(util.getValue(lines, 'CurrentVerticalResolution', '='));
_refreshrate = util.toInt(util.getValue(lines, 'CurrentRefreshRate', '='));
_pixeldepth = util.toInt(util.getValue(lines, 'CurrentBitsPerPixel', '='));
_resolutionx = util.toInt(util.getValue(lines, 'CurrentHorizontalResolution', '=')) || _resolutionx;
_resolutiony = util.toInt(util.getValue(lines, 'CurrentVerticalResolution', '=')) || _resolutiony;
_refreshrate = util.toInt(util.getValue(lines, 'CurrentRefreshRate', '=')) || _refreshrate;
_pixeldepth = util.toInt(util.getValue(lines, 'CurrentBitsPerPixel', '=')) || _pixeldepth;
}
}
}
......@@ -677,18 +693,21 @@ function graphics(callback) {
// return displays;
// }
function parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections) {
function parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections, isections) {
let displays = [];
let vendor = '';
let model = '';
let deviceID = '';
let resolutionx = 0;
let resolutiony = 0;
if (dsections && dsections.length) {
let linesDisplay = dsections[0].split(os.EOL);
vendor = util.getValue(linesDisplay, 'MonitorManufacturer', '=');
model = util.getValue(linesDisplay, 'Name', '=');
deviceID = util.getValue(linesDisplay, 'PNPDeviceID', '=').replace(/&amp;/g, '&').toLowerCase();
resolutionx = util.toInt(util.getValue(linesDisplay, 'ScreenWidth', '='));
resolutiony = util.toInt(util.getValue(linesDisplay, 'ScreenHeight', '='));
}
for (let i = 0; i < ssections.length; i++) {
if (ssections[i].trim() !== '') {
ssections[i] = 'BitsPerPixel ' + ssections[i];
......@@ -704,9 +723,17 @@ function graphics(callback) {
const sizey = util.getValue(linesMonitor, 'MaxVerticalImageSize');
const instanceName = util.getValue(linesMonitor, 'InstanceName').toLowerCase();
const videoOutputTechnology = util.getValue(linesConnection, 'VideoOutputTechnology');
let displayVendor = '';
let displayModel = '';
isections.forEach(element => {
if (element.instanceId.toLowerCase().startsWith(instanceName) && vendor.startsWith('(') && model.startsWith('PnP')) {
displayVendor = element.vendor;
displayModel = element.model;
}
});
displays.push({
vendor: instanceName.startsWith(deviceID) ? vendor : '',
model: instanceName.startsWith(deviceID) ? model : '',
vendor: instanceName.startsWith(deviceID) && displayVendor === '' ? vendor : displayVendor,
model: instanceName.startsWith(deviceID) && displayModel === '' ? model : displayModel,
main: primary.toLowerCase() === 'true',
builtin: videoOutputTechnology === '2147483648',
connection: videoOutputTechnology && videoTypes[videoOutputTechnology] ? videoTypes[videoOutputTechnology] : '',
......@@ -722,6 +749,22 @@ function graphics(callback) {
});
}
}
if (ssections.length === 0) {
displays.push({
vendor,
model,
main: true,
resolutionx,
resolutiony,
sizex: -1,
sizey: -1,
pixeldepth: -1,
currentResX: resolutionx,
currentResY: resolutiony,
positionX: 0,
positionY: 0
});
}
return displays;
}
......
......@@ -785,7 +785,7 @@ function networkConnections(callback) {
let lines = stdout.toString().split('\n');
lines.forEach(function (line) {
line = line.replace(/ +/g, ' ').split(' ');
if (line.length >= 6) {
if (line.length >= 7) {
let localip = line[3];
let localport = '';
let localaddress = line[3].split(':');
......
......@@ -178,7 +178,7 @@ function parseDateTime(dt) {
// Dateformat: mm/dd/yyyy
result.date = dtparts[2] + '-' + ('0' + dtparts[0]).substr(-2) + '-' + ('0' + dtparts[1]).substr(-2);
} else {
// Dateformat: dd/mm/yyyy
// Dateformat: dd/mm/yyyy
result.date = dtparts[2] + '-' + ('0' + dtparts[1]).substr(-2) + '-' + ('0' + dtparts[0]).substr(-2);
}
}
......@@ -321,6 +321,11 @@ function powerShell(cmd) {
stdio: 'pipe'
});
if (child && !child.pid) {
child.on('error', function () {
resolve(result);
});
}
if (child && child.pid) {
child.stdout.on('data', function (data) {
result = result + data.toString('utf8');
......@@ -454,6 +459,7 @@ function countUniqueLines(lines, startingWith) {
});
return uniqueLines.length;
}
function noop() { }
exports.toInt = toInt;
......
{
"_from": "systeminformation",
"_id": "systeminformation@4.14.11",
"_from": "systeminformation@4.14.17",
"_id": "systeminformation@4.14.17",
"_inBundle": false,
"_integrity": "sha512-KlMaQQftyGUPjKzGRrATN5mpKrpdtrVk/KPuqPeu733bUgpokIhevg5zjKOb4Gur91XKdbdQCCja/oFsg5R4Dw==",
"_integrity": "sha512-CQbT5vnkqNb3JNl41xr8sYA8AX7GoaWP55/jnmFNQY0XQmUuoFshSNUkCkxiDdEC1qu2Vg9s0jR6LLmVSmNJUw==",
"_location": "/systeminformation",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"type": "version",
"registry": true,
"raw": "systeminformation",
"raw": "systeminformation@4.14.17",
"name": "systeminformation",
"escapedName": "systeminformation",
"rawSpec": "",
"rawSpec": "4.14.17",
"saveSpec": null,
"fetchSpec": "latest"
"fetchSpec": "4.14.17"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-4.14.11.tgz",
"_shasum": "5c7f23d92586f2639a9d037a359890f7ab01c4ea",
"_spec": "systeminformation",
"_where": "C:\\Users\\thequ\\Documents\\Mynij",
"_resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-4.14.17.tgz",
"_shasum": "c7ba98a63835785c3e8df711c0e0730cc3b1b2ce",
"_spec": "systeminformation@4.14.17",
"_where": "C:\\Users\\thequ\\Documents\\Mynij\\Mynij-unit-tests",
"author": {
"name": "Sebastian Hildebrandt",
"email": "hildebrandt@plus-innovations.com",
......@@ -146,5 +146,5 @@
"watch": "tsc -w"
},
"types": "./lib/index.d.ts",
"version": "4.14.11"
"version": "4.14.17"
}
export {PackageJson} from './source/package-json';