New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bunchmark/core

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bunchmark/core - npm Package Compare versions

Comparing version 1.0.0-pre-8 to 1.0.0-pre-9

2

package.json
{
"name": "@bunchmark/core",
"version": "1.0.0-pre-8",
"version": "1.0.0-pre-9",
"description": "benchmarking lib",

@@ -5,0 +5,0 @@ "type": "module",

@@ -35,10 +35,7 @@ // @ts-check

const randStr = () => (Math.random() * 0x7fffffff | 0).toString(36);
const uid = [randStr(), randStr(), randStr(), randStr()].join("_");
const result_uid = `result_${uid}`;
const now_id = `now_${uid}`;
const uid = () => [randStr(), randStr(), randStr(), randStr()].join("_");
const hasPerf = typeof performance !== "undefined";
const header = `
const ${result_uid} = [];
const ${now_id} = ${hasPerf ? "() => performance.now()" : "process.hrtime.bigint"}
`;
// .now() is a method, it needs a performance object as this
const getTime = hasPerf ? "() => performance.now()" : "process.hrtime.bigint"
/**

@@ -52,11 +49,14 @@ * @param {string} result_uid

const N = "N_" + uid;
/**
* @param {Task} task // TODO find a way to use {Task} instead of {object}
* @param {Task} task
* @param {Code} beforeEach
* @param {Code} afterEach
* @param {string} now_id
* @param {string} result_uid
* @returns {string}
*/
const bakeTask = ({ run, before = "", after = "" }, beforeEach, afterEach) => `
const bakeTask = ({ run, before = "", after = "" }, beforeEach, afterEach, now_id, result_uid) => {
const N = "N_" + uid()
return `
${result_uid}.push(async function(${N}){

@@ -74,5 +74,4 @@ ${stringify({ beforeEach })};

});
`;
`};
/**

@@ -83,8 +82,13 @@ * @param {Bakable} bakable

function bake({ tasks, preamble = "", beforeEach = "", afterEach = "", footer }) {
return `
${stringify({ preamble })};
const result_uid = `result_${uid()}`
const now_id = `now_${uid()}`
${header};
return `
let result
setTimeout(()=>{console.log(result)}, 2**31 - 1)
;${stringify({ preamble })};
${tasks.map(task => bakeTask(task, beforeEach, afterEach)).join("")}
const ${result_uid} = []
const ${now_id} = ${getTime}
${tasks.map((task) => bakeTask(task, beforeEach, afterEach, now_id, result_uid)).join("")}

@@ -91,0 +95,0 @@ ${footer(result_uid)}

@@ -70,4 +70,2 @@ export { run };

const { sample, result, result: { workspace, chronological, calibration }, keepChrono } = task;
if (typeof sample !== 'function')
debugger;
let N = 1;

@@ -107,3 +105,3 @@ for (;;) {

const reps = ceil(N * jitterFactor)
const t = await sample(reps) / reps;
const t = (await sample(reps)) / reps;
result.workspace.push(t);

@@ -114,3 +112,2 @@ if (keepChrono)

/**

@@ -225,4 +222,6 @@ * @param {RunnerOptions} options

reject(e);
return;
}
if (status == null) throw new TypeError("Unexpected null") // TS flow analysis is lacking here
// appease TypeScript, this can't ever be null
if (status == null) throw new TypeError("Unexpected null")
if (!status.done) {

@@ -229,0 +228,0 @@ if (!isTick(status))

@@ -0,1 +1,4 @@

// This can be useful:
// https://alexharri.com/blog/jsdoc-as-an-alternative-typescript-syntax
export type Sampler = ((N: number)=>Promise<number>)

@@ -2,0 +5,0 @@

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