Socket
Socket
Sign inDemoInstall

cronometro

Package Overview
Dependencies
23
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 1.1.3

dist/index.d.ts

6

CHANGELOG.md

@@ -0,1 +1,7 @@

### 2022-10-12 / 1.1.3
- fix: Updated types layout.
- chore: Updated compilation configuration.
- chore: Remove lint rule.
### 2022-08-30 / 1.1.2

@@ -2,0 +8,0 @@

36

dist/index.js

@@ -1,5 +0,5 @@

import { isMainThread, Worker, workerData } from "node:worker_threads";
import { defaultOptions, runnerPath } from "./models.js";
import { printResults } from "./print.js";
export * from "./models.js";
import { isMainThread, Worker, workerData } from 'node:worker_threads';
import { defaultOptions, runnerPath } from './models.js';
import { printResults } from './print.js';
export * from './models.js';
function scheduleNextTest(context) {

@@ -14,3 +14,3 @@ // We still have work to do

compare: false,
compareMode: "base",
compareMode: 'base',
...context.print === true ? {} : context.print

@@ -37,3 +37,3 @@ };

}
worker.on("error", (error)=>{
worker.on('error', (error)=>{
context.results[name] = {

@@ -56,3 +56,3 @@ success: false,

});
worker.on("message", (result)=>{
worker.on('message', (result)=>{
context.results[name] = result;

@@ -74,3 +74,3 @@ context.current++;

let promiseReject;
if (typeof options === "function") {
if (typeof options === 'function') {
cb = options;

@@ -97,20 +97,20 @@ options = {};

};
if (typeof iterations !== "number" || iterations < 1) {
callback(new Error("The iterations option must be a positive number."));
if (typeof iterations !== 'number' || iterations < 1) {
callback(new Error('The iterations option must be a positive number.'));
return promise;
}
if (typeof errorThreshold !== "number" || errorThreshold < 0 || errorThreshold > 100) {
callback(new Error("The errorThreshold option must be a number between 0 and 100."));
if (typeof errorThreshold !== 'number' || errorThreshold < 0 || errorThreshold > 100) {
callback(new Error('The errorThreshold option must be a number between 0 and 100.'));
return promise;
}
if (onTestStart && typeof onTestStart !== "function") {
callback(new Error("The onTestStart option must be a function."));
if (onTestStart && typeof onTestStart !== 'function') {
callback(new Error('The onTestStart option must be a function.'));
return promise;
}
if (onTestEnd && typeof onTestEnd !== "function") {
callback(new Error("The onTestEnd option must be a function."));
if (onTestEnd && typeof onTestEnd !== 'function') {
callback(new Error('The onTestEnd option must be a function.'));
return promise;
}
if (onTestError && typeof onTestError !== "function") {
callback(new Error("The onTestError option must be a function."));
if (onTestError && typeof onTestError !== 'function') {
callback(new Error('The onTestError option must be a function.'));
return promise;

@@ -117,0 +117,0 @@ }

@@ -1,2 +0,2 @@

import { resolve } from "node:path";
import { resolve } from 'node:path';
export const defaultOptions = {

@@ -25,2 +25,2 @@ iterations: 1e4,

];
export const runnerPath = resolve(import.meta.url.replace("file://", "").replace(/models.(js|ts)/, ""), "./runner.js");
export const runnerPath = resolve(import.meta.url.replace('file://', '').replace(/models.(js|ts)/, ''), './runner.js');

@@ -1,12 +0,12 @@

import { clean, colorize } from "acquerello";
import { table } from "table";
import { clean, colorize } from 'acquerello';
import { table } from 'table';
const styles = [
"red",
"green",
"yellow",
"blue",
"magenta",
"cyan",
"white",
"gray"
'red',
'green',
'yellow',
'blue',
'magenta',
'cyan',
'white',
'gray'
];

@@ -21,3 +21,3 @@ let currentLogger = console.log;

let last = 0;
let compared = "";
let compared = '';
let standardErrorPadding = 0;

@@ -30,6 +30,6 @@ const entries = Object.entries(results).sort((a, b)=>!a[1].success ? -1 : b[1].mean - a[1].mean).map(([name, result])=>{

error: result.error,
throughput: "",
standardError: "",
relative: "",
compared: ""
throughput: '',
standardError: '',
relative: '',
compared: ''
};

@@ -39,3 +39,3 @@ }

const relative = last !== 0 ? (last / mean - 1) * 100 : 0;
if (mode === "base") {
if (mode === 'base') {
if (last === 0) {

@@ -67,7 +67,7 @@ last = mean;

styler(`{{gray}}${entry.size}{{-}}`),
styler("{{gray}}Errored{{-}}"),
styler("{{gray}}N/A{{-}}")
styler('{{gray}}Errored{{-}}'),
styler('{{gray}}N/A{{-}}')
];
if (compare) {
row.push(styler("{{gray}}N/A{{-}}"));
row.push(styler('{{gray}}N/A{{-}}'));
}

@@ -82,7 +82,7 @@ return row;

styler(`{{${color}}}${throughput} op/sec{{-}}`),
styler(`{{gray}}± ${standardError.padStart(standardErrorPadding, " ")} %{{-}}`)
styler(`{{gray}}± ${standardError.padStart(standardErrorPadding, ' ')} %{{-}}`)
];
if (compare) {
if (/^[\s.0]+$/.test(relative)) {
row1.push("");
row1.push('');
} else {

@@ -94,14 +94,14 @@ row1.push(styler(`{{${color}}}+ ${relative} %{{-}}`));

});
const compareHeader = `Difference with ${mode === "base" ? "slowest" : "previous"}`;
const compareHeader = `Difference with ${mode === 'base' ? 'slowest' : 'previous'}`;
rows.unshift([
styler("{{bold white}}Slower tests{{-}}"),
styler("{{bold white}}Samples{{-}}"),
styler("{{bold white}}Result{{-}}"),
styler("{{bold white}}Tolerance{{-}}")
styler('{{bold white}}Slower tests{{-}}'),
styler('{{bold white}}Samples{{-}}'),
styler('{{bold white}}Result{{-}}'),
styler('{{bold white}}Tolerance{{-}}')
]);
rows.splice(-1, 0, [
styler("{{bold white}}Fastest test{{-}}"),
styler("{{bold white}}Samples{{-}}"),
styler("{{bold white}}Result{{-}}"),
styler("{{bold white}}Tolerance{{-}}")
styler('{{bold white}}Fastest test{{-}}'),
styler('{{bold white}}Samples{{-}}'),
styler('{{bold white}}Result{{-}}'),
styler('{{bold white}}Tolerance{{-}}')
]);

@@ -115,12 +115,12 @@ if (compare) {

0: {
alignment: "left"
alignment: 'left'
},
1: {
alignment: "right"
alignment: 'right'
},
2: {
alignment: "right"
alignment: 'right'
},
3: {
alignment: "right"
alignment: 'right'
}

@@ -127,0 +127,0 @@ },

@@ -1,13 +0,13 @@

import { isMainThread, parentPort, workerData } from "node:worker_threads";
import { runWorker } from "./worker.js";
import { isMainThread, parentPort, workerData } from 'node:worker_threads';
import { runWorker } from './worker.js';
if (isMainThread) {
throw new Error("Do not run this file as main script.");
throw new Error('Do not run this file as main script.');
}
// Register ts-node for TypeScript inclusion
let chain = Promise.resolve();
/* c8 ignore start */ if (workerData.path.endsWith(".ts")) {
const instance = Symbol.for("ts-node.register.instance");
/* c8 ignore start */ if (workerData.path.endsWith('.ts')) {
const instance = Symbol.for('ts-node.register.instance');
if (!(instance in process)) {
// eslint-disable-next-line unicorn/prefer-top-level-await
chain = import("ts-node").then(({ register })=>{
chain = import('ts-node').then(({ register })=>{
register({

@@ -23,5 +23,5 @@ project: process.env.TS_NODE_PROJECT

}).then((module)=>{
if (typeof module === "function") {
if (typeof module === 'function') {
return module();
} else if (typeof module.default === "function") {
} else if (typeof module.default === 'function') {
return module.default();

@@ -28,0 +28,0 @@ }

@@ -1,3 +0,3 @@

import { build as buildHistogram } from "hdr-histogram-js";
import { percentiles } from "./models.js";
import { build as buildHistogram } from 'hdr-histogram-js';
import { percentiles } from './models.js';
function noOp() {

@@ -35,3 +35,3 @@ // No-op

if (errorThreshold > 0) {
const completedPercentage = Math.floor(executed / total * 10000);
const completedPercentage = Math.floor(executed / total * 10_000);
// Check if abort the test earlier. It is checked every 5% after 10% of the iterations

@@ -71,3 +71,3 @@ if (completedPercentage >= 1000 && completedPercentage % 500 === 0) {

// It is a promise, handle it accordingly
if (callResult && typeof callResult.then === "function") {
if (callResult && typeof callResult.then === 'function') {
callResult.then(()=>context.handler(null), context.handler);

@@ -131,12 +131,12 @@ } else if (context.test.length === 0) {

let after = noSetup;
if (typeof testDefinition === "function") {
if (typeof testDefinition === 'function') {
test = testDefinition;
} else {
if (typeof testDefinition.test === "function") {
if (typeof testDefinition.test === 'function') {
test = testDefinition.test;
}
if (typeof testDefinition.before === "function") {
if (typeof testDefinition.before === 'function') {
before = testDefinition.before;
}
if (typeof testDefinition.after === "function") {
if (typeof testDefinition.after === 'function') {
after = testDefinition.after;

@@ -167,3 +167,3 @@ }

const afterResponse = after(callback);
if (afterResponse && typeof afterResponse.then === "function") {
if (afterResponse && typeof afterResponse.then === 'function') {
afterResponse.then(callback, callback);

@@ -178,5 +178,5 @@ }

const beforeResponse = before(callback);
if (beforeResponse && typeof beforeResponse.then === "function") {
if (beforeResponse && typeof beforeResponse.then === 'function') {
beforeResponse.then(callback, callback);
}
}
{
"name": "cronometro",
"version": "1.1.2",
"version": "1.1.3",
"description": "Simple benchmarking suite powered by HDR histograms.",

@@ -26,10 +26,9 @@ "homepage": "https://sw.cowtech.it/cronometro",

"exports": "./dist/index.js",
"typings": "./types/index.d.ts",
"types": "./types/index.d.ts",
"types": "./dist/index.d.ts",
"scripts": {
"dev": "swc -s -w -d dist src",
"prebuild": "rm -rf dist types && npm run typecheck && npm run lint",
"build": "swc --delete-dir-on-start -d dist src",
"prebuild": "rm -rf dist && npm run lint",
"build": "swc -d dist src",
"postbuild": "tsc -p . --emitDeclarationOnly",
"format": "prettier -w src test",
"typecheck": "tsc -p . --emitDeclarationOnly",
"lint": "eslint src test",

@@ -43,3 +42,3 @@ "test": "c8 -c test/config/c8-local.json tap --rcfile=test/config/tap.yml test/*.test.ts",

"dependencies": {
"acquerello": "^1.0.9",
"acquerello": "^1.0.10",
"hdr-histogram-js": "^3.0.0",

@@ -49,6 +48,6 @@ "table": "^6.8.0"

"devDependencies": {
"@cowtech/eslint-config": "^8.7.2",
"@cowtech/eslint-config": "^8.7.5",
"@swc/cli": "^0.1.57",
"@swc/core": "^1.2.245",
"@types/node": "^18.7.14",
"@swc/core": "^1.3.7",
"@types/node": "^18.8.4",
"@types/sinon": "^10.0.13",

@@ -60,6 +59,6 @@ "@types/tap": "^15.0.7",

"proxyquire": "^2.1.3",
"sinon": "^14.0.0",
"sinon": "^14.0.1",
"tap": "^16.3.0",
"ts-node": "^10.9.1",
"typescript": "^4.8.2"
"typescript": "^4.8.4"
},

@@ -66,0 +65,0 @@ "engines": {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc