Socket
Socket
Sign inDemoInstall

node-opcua-benchmarker

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-opcua-benchmarker - npm Package Compare versions

Comparing version 2.110.0 to 2.114.0

./dist/index.js

89

dist/benchmarker.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -20,9 +11,7 @@ exports.Benchmarker = void 0;

const node_opcua_utils_1 = require("node-opcua-utils");
function measure_cycle(func) {
return __awaiter(this, void 0, void 0, function* () {
const start = (0, node_opcua_utils_1.hrtime)(); // tuple [second, nanosecond]
yield func();
const elapsed = (0, node_opcua_utils_1.hrtime)(start);
return elapsed[0] + elapsed[1] / 1000000000;
});
async function measure_cycle(func) {
const start = (0, node_opcua_utils_1.hrtime)(); // tuple [second, nanosecond]
await func();
const elapsed = (0, node_opcua_utils_1.hrtime)(start);
return elapsed[0] + elapsed[1] / 1000000000;
}

@@ -60,18 +49,16 @@ function minimum(arr, predicate) {

*/
run(options) {
return __awaiter(this, void 0, void 0, function* () {
options = options || {};
options.max_time = !options.max_time ? 0.5 : options.max_time;
options.min_count = options.min_count || 5;
for (const test of Object.values(this.suites)) {
test.result = yield this.measure_perf(test.name, test.functor, options);
}
const pred = (bench) => bench.result.ops;
// find fastest
this.fastest = maximum(Object.values(this.suites), pred);
this.slowest = minimum(Object.values(this.suites), pred);
this.speedUp = Math.floor(this.fastest.result.ops / this.slowest.result.ops);
this.emit("complete", this.fastest, this.speedUp);
return this;
});
async run(options) {
options = options || {};
options.max_time = !options.max_time ? 0.5 : options.max_time;
options.min_count = options.min_count || 5;
for (const test of Object.values(this.suites)) {
test.result = await this.measure_perf(test.name, test.functor, options);
}
const pred = (bench) => bench.result.ops;
// find fastest
this.fastest = maximum(Object.values(this.suites), pred);
this.slowest = minimum(Object.values(this.suites), pred);
this.speedUp = Math.floor(this.fastest.result.ops / this.slowest.result.ops);
this.emit("complete", this.fastest, this.speedUp);
return this;
}

@@ -85,22 +72,20 @@ /**

*/
measure_perf(name, func, options) {
return __awaiter(this, void 0, void 0, function* () {
let totalTime = 0;
let count = 0;
const maxTime = !options.max_time ? 0.5 : options.max_time;
const minCount = options.min_count || 5;
while (totalTime < maxTime || count < minCount) {
totalTime += yield measure_cycle(func);
count += 1;
}
const ops = count / totalTime;
const message = " CYCLE " + name + " op/s " + ((count / totalTime).toPrecision(7) + " count = " + count);
this.emit("cycle", message);
return {
count: count,
message: message,
ops: ops,
total_time: totalTime,
};
});
async measure_perf(name, func, options) {
let totalTime = 0;
let count = 0;
const maxTime = !options.max_time ? 0.5 : options.max_time;
const minCount = options.min_count || 5;
while (totalTime < maxTime || count < minCount) {
totalTime += await measure_cycle(func);
count += 1;
}
const ops = count / totalTime;
const message = " CYCLE " + name + " op/s " + ((count / totalTime).toPrecision(7) + " count = " + count);
this.emit("cycle", message);
return {
count: count,
message: message,
ops: ops,
total_time: totalTime,
};
}

@@ -107,0 +92,0 @@ }

{
"name": "node-opcua-benchmarker",
"version": "2.110.0",
"version": "2.114.0",
"description": "pure nodejs OPCUA SDK - module benchmarker",

@@ -13,3 +13,3 @@ "main": "./dist/index.js",

"dependencies": {
"node-opcua-utils": "2.110.0"
"node-opcua-utils": "2.114.0"
},

@@ -31,3 +31,3 @@ "author": "Etienne Rossignon",

"homepage": "http://node-opcua.github.io/",
"gitHead": "f419b91486436bfd804d5d66d2b77db834a4deaf",
"gitHead": "358d284a696c88e383eedac1ab75d950fb28ec35",
"files": [

@@ -34,0 +34,0 @@ "dist",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc