UNPKG

cronometro

Version:

Simple benchmarking suite powered by HDR histograms.

31 lines (30 loc) 1.15 kB
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) { if (typeof path === "string" && /^\.\.?\//.test(path)) { return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) { return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js"); }); } return path; }; 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.'); } try { const module = await import(__rewriteRelativeImportExtension(workerData.path, true)); if (typeof module === 'function') { await module(); } else if (typeof module.default === 'function') { await module.default(); } runWorker(workerData, value => { parentPort.postMessage({ type: 'cronometro.result', payload: value }); }, (code) => process.exit(code)); } catch (error) { process.nextTick(() => { throw error; }); }