@codspeed/tinybench-plugin 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,6 +6,7 @@ tinybench compatibility layer for CodSpeed
6
6
  [![CI](https://github.com/CodSpeedHQ/codspeed-node/actions/workflows/ci.yml/badge.svg)](https://github.com/CodSpeedHQ/codspeed-node/actions/workflows/ci.yml)
7
7
  [![npm (scoped)](https://img.shields.io/npm/v/@codspeed/tinybench-plugin)](https://www.npmjs.com/package/@codspeed/tinybench-plugin)
8
8
  [![Discord](https://img.shields.io/badge/chat%20on-discord-7289da.svg)](https://discord.com/invite/MxpaCfKSqF)
9
+ [![CodSpeed Badge](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/CodSpeedHQ/codspeed-node)
9
10
 
10
11
  </div>
11
12
 
package/dist/index.cjs.js CHANGED
@@ -1,112 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var core = require('@codspeed/core');
4
- var path = require('node:path');
5
- var node_url = require('node:url');
6
- var process = require('node:process');
7
- var fs = require('node:fs');
8
- var path$1 = require('path');
4
+ var path = require('path');
9
5
  var url = require('url');
10
6
 
11
- const typeMappings = {
12
- directory: 'isDirectory',
13
- file: 'isFile',
14
- };
15
-
16
- function checkType(type) {
17
- if (Object.hasOwnProperty.call(typeMappings, type)) {
18
- return;
19
- }
20
-
21
- throw new Error(`Invalid type specified: ${type}`);
22
- }
23
-
24
- const matchType = (type, stat) => stat[typeMappings[type]]();
25
-
26
- const toPath$1 = urlOrPath => urlOrPath instanceof URL ? node_url.fileURLToPath(urlOrPath) : urlOrPath;
27
-
28
- function locatePathSync(
29
- paths,
30
- {
31
- cwd = process.cwd(),
32
- type = 'file',
33
- allowSymlinks = true,
34
- } = {},
35
- ) {
36
- checkType(type);
37
- cwd = toPath$1(cwd);
38
-
39
- const statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;
40
-
41
- for (const path_ of paths) {
42
- try {
43
- const stat = statFunction(path.resolve(cwd, path_), {
44
- throwIfNoEntry: false,
45
- });
46
-
47
- if (!stat) {
48
- continue;
49
- }
50
-
51
- if (matchType(type, stat)) {
52
- return path_;
53
- }
54
- } catch {}
55
- }
56
- }
57
-
58
- const toPath = urlOrPath => urlOrPath instanceof URL ? node_url.fileURLToPath(urlOrPath) : urlOrPath;
59
-
60
- const findUpStop = Symbol('findUpStop');
61
-
62
- function findUpMultipleSync(name, options = {}) {
63
- let directory = path.resolve(toPath(options.cwd) || '');
64
- const {root} = path.parse(directory);
65
- const stopAt = options.stopAt || root;
66
- const limit = options.limit || Number.POSITIVE_INFINITY;
67
- const paths = [name].flat();
68
-
69
- const runMatcher = locateOptions => {
70
- if (typeof name !== 'function') {
71
- return locatePathSync(paths, locateOptions);
72
- }
73
-
74
- const foundPath = name(locateOptions.cwd);
75
- if (typeof foundPath === 'string') {
76
- return locatePathSync([foundPath], locateOptions);
77
- }
78
-
79
- return foundPath;
80
- };
81
-
82
- const matches = [];
83
- // eslint-disable-next-line no-constant-condition
84
- while (true) {
85
- const foundPath = runMatcher({...options, cwd: directory});
86
-
87
- if (foundPath === findUpStop) {
88
- break;
89
- }
90
-
91
- if (foundPath) {
92
- matches.push(path.resolve(directory, foundPath));
93
- }
94
-
95
- if (directory === stopAt || matches.length >= limit) {
96
- break;
97
- }
98
-
99
- directory = path.dirname(directory);
100
- }
101
-
102
- return matches;
103
- }
104
-
105
- function findUpSync(name, options = {}) {
106
- const matches = findUpMultipleSync(name, {...options, limit: 1});
107
- return matches[0];
108
- }
109
-
110
7
  function get(belowFn) {
111
8
  const oldLimit = Error.stackTraceLimit;
112
9
  Error.stackTraceLimit = Infinity;
@@ -165,6 +62,7 @@ boolProperties.forEach(function (property) {
165
62
  };
166
63
  });
167
64
 
65
+ core.tryIntrospect();
168
66
  function isCodSpeedBenchOptions(options) {
169
67
  return "uri" in options;
170
68
  }
@@ -183,31 +81,29 @@ function withCodSpeed(bench) {
183
81
  bench.add = (name, fn, opts) => {
184
82
  const callingFile = getCallingFile();
185
83
  const uri = `${callingFile}::${name}`;
186
- const options = Object.assign({}, opts != null ? opts : {}, { uri });
84
+ const options = Object.assign({}, opts ?? {}, { uri });
187
85
  return rawAdd.bind(bench)(name, fn, options);
188
86
  };
189
87
  const rootCallingFile = getCallingFile();
190
88
  bench.run = async () => {
191
- var _a, _b, _c, _d;
192
- console.log(`[CodSpeed] running with @codspeed/tinybench v${"2.2.0"}`);
89
+ console.log(`[CodSpeed] running with @codspeed/tinybench v${"2.3.0"}`);
193
90
  core.setupCore();
194
91
  for (const task of bench.tasks) {
195
92
  const uri = isCodSpeedBenchOptions(task.opts) ? task.opts.uri : `${rootCallingFile}::${task.name}`;
196
- await ((_a = task.opts.beforeAll) == null ? void 0 : _a.call(task));
93
+ await task.opts.beforeAll?.call(task);
197
94
  await core.optimizeFunction(async () => {
198
- var _a2, _b2;
199
- await ((_a2 = task.opts.beforeEach) == null ? void 0 : _a2.call(task));
95
+ await task.opts.beforeEach?.call(task);
200
96
  await task.fn();
201
- await ((_b2 = task.opts.afterEach) == null ? void 0 : _b2.call(task));
97
+ await task.opts.afterEach?.call(task);
202
98
  });
203
- await ((_b = task.opts.beforeEach) == null ? void 0 : _b.call(task));
99
+ await task.opts.beforeEach?.call(task);
204
100
  await async function __codspeed_root_frame__() {
205
101
  core.Measurement.startInstrumentation();
206
102
  await task.fn();
207
103
  core.Measurement.stopInstrumentation(uri);
208
104
  }();
209
- await ((_c = task.opts.afterEach) == null ? void 0 : _c.call(task));
210
- await ((_d = task.opts.afterAll) == null ? void 0 : _d.call(task));
105
+ await task.opts.afterEach?.call(task);
106
+ await task.opts.afterAll?.call(task);
211
107
  console.log(` \u2714 Measured ${uri}`);
212
108
  }
213
109
  core.teardownCore();
@@ -219,21 +115,14 @@ function withCodSpeed(bench) {
219
115
  function getCallingFile() {
220
116
  const stack = get();
221
117
  let callingFile = stack[2].getFileName();
222
- const gitDir = getGitDir(callingFile);
118
+ const gitDir = core.getGitDir(callingFile);
223
119
  if (gitDir === void 0) {
224
120
  throw new Error("Could not find a git repository");
225
121
  }
226
122
  if (callingFile.startsWith("file://")) {
227
123
  callingFile = url.fileURLToPath(callingFile);
228
124
  }
229
- return path$1.relative(gitDir, callingFile);
230
- }
231
- function getGitDir(path2) {
232
- const dotGitPath = findUpSync(".git", {
233
- cwd: path2,
234
- type: "directory"
235
- });
236
- return dotGitPath ? path$1.dirname(dotGitPath) : void 0;
125
+ return path.relative(gitDir, callingFile);
237
126
  }
238
127
 
239
128
  exports.withCodSpeed = withCodSpeed;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js","../../../node_modules/.pnpm/find-up@6.3.0/node_modules/find-up/index.js","../../../node_modules/.pnpm/stack-trace@1.0.0-pre2/node_modules/stack-trace/index.js","../src/index.ts"],"sourcesContent":["import process from 'node:process';\nimport path from 'node:path';\nimport fs, {promises as fsPromises} from 'node:fs';\nimport {fileURLToPath} from 'node:url';\nimport pLocate from 'p-locate';\n\nconst typeMappings = {\n\tdirectory: 'isDirectory',\n\tfile: 'isFile',\n};\n\nfunction checkType(type) {\n\tif (Object.hasOwnProperty.call(typeMappings, type)) {\n\t\treturn;\n\t}\n\n\tthrow new Error(`Invalid type specified: ${type}`);\n}\n\nconst matchType = (type, stat) => stat[typeMappings[type]]();\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport async function locatePath(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t\tconcurrency,\n\t\tpreserveOrder,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;\n\n\treturn pLocate(paths, async path_ => {\n\t\ttry {\n\t\t\tconst stat = await statFunction(path.resolve(cwd, path_));\n\t\t\treturn matchType(type, stat);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}, {concurrency, preserveOrder});\n}\n\nexport function locatePathSync(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;\n\n\tfor (const path_ of paths) {\n\t\ttry {\n\t\t\tconst stat = statFunction(path.resolve(cwd, path_), {\n\t\t\t\tthrowIfNoEntry: false,\n\t\t\t});\n\n\t\t\tif (!stat) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (matchType(type, stat)) {\n\t\t\t\treturn path_;\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n","import path from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {locatePath, locatePathSync} from 'locate-path';\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport const findUpStop = Symbol('findUpStop');\n\nexport async function findUpMultiple(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) || '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = path.resolve(directory, options.stopAt || root);\n\tconst limit = options.limit || Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = async locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePath(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = await name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePath([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tconst foundPath = await runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport function findUpMultipleSync(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) || '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = options.stopAt || root;\n\tconst limit = options.limit || Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePathSync(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePathSync([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\tconst foundPath = runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport async function findUp(name, options = {}) {\n\tconst matches = await findUpMultiple(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport function findUpSync(name, options = {}) {\n\tconst matches = findUpMultipleSync(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport {\n\tpathExists,\n\tpathExistsSync,\n} from 'path-exists';\n","export function get(belowFn) {\r\n const oldLimit = Error.stackTraceLimit;\r\n Error.stackTraceLimit = Infinity;\r\n\r\n const dummyObject = {};\r\n\r\n const v8Handler = Error.prepareStackTrace;\r\n Error.prepareStackTrace = function(dummyObject, v8StackTrace) {\r\n return v8StackTrace;\r\n };\r\n Error.captureStackTrace(dummyObject, belowFn || get);\r\n\r\n const v8StackTrace = dummyObject.stack;\r\n Error.prepareStackTrace = v8Handler;\r\n Error.stackTraceLimit = oldLimit;\r\n\r\n return v8StackTrace;\r\n}\r\n\r\nexport function parse(err) {\r\n if (!err.stack) {\r\n return [];\r\n }\r\n\r\n const lines = err.stack.split('\\n').slice(1);\r\n return lines\r\n .map(function(line) {\r\n if (line.match(/^\\s*[-]{4,}$/)) {\r\n return createParsedCallSite({\r\n fileName: line,\r\n lineNumber: null,\r\n functionName: null,\r\n typeName: null,\r\n methodName: null,\r\n columnNumber: null,\r\n 'native': null,\r\n });\r\n }\r\n\r\n const lineMatch = line.match(/at (?:(.+?)\\s+\\()?(?:(.+?):(\\d+)(?::(\\d+))?|([^)]+))\\)?/);\r\n if (!lineMatch) {\r\n return;\r\n }\r\n\r\n let object = null;\r\n let method = null;\r\n let functionName = null;\r\n let typeName = null;\r\n let methodName = null;\r\n let isNative = (lineMatch[5] === 'native');\r\n\r\n if (lineMatch[1]) {\r\n functionName = lineMatch[1];\r\n let methodStart = functionName.lastIndexOf('.');\r\n if (functionName[methodStart-1] == '.')\r\n methodStart--;\r\n if (methodStart > 0) {\r\n object = functionName.substr(0, methodStart);\r\n method = functionName.substr(methodStart + 1);\r\n const objectEnd = object.indexOf('.Module');\r\n if (objectEnd > 0) {\r\n functionName = functionName.substr(objectEnd + 1);\r\n object = object.substr(0, objectEnd);\r\n }\r\n }\r\n }\r\n\r\n if (method) {\r\n typeName = object;\r\n methodName = method;\r\n }\r\n\r\n if (method === '<anonymous>') {\r\n methodName = null;\r\n functionName = null;\r\n }\r\n\r\n const properties = {\r\n fileName: lineMatch[2] || null,\r\n lineNumber: parseInt(lineMatch[3], 10) || null,\r\n functionName: functionName,\r\n typeName: typeName,\r\n methodName: methodName,\r\n columnNumber: parseInt(lineMatch[4], 10) || null,\r\n 'native': isNative,\r\n };\r\n\r\n return createParsedCallSite(properties);\r\n })\r\n .filter(function(callSite) {\r\n return !!callSite;\r\n });\r\n}\r\n\r\nfunction CallSite(properties) {\r\n for (const property in properties) {\r\n this[property] = properties[property];\r\n }\r\n}\r\n\r\nconst strProperties = [\r\n 'this',\r\n 'typeName',\r\n 'functionName',\r\n 'methodName',\r\n 'fileName',\r\n 'lineNumber',\r\n 'columnNumber',\r\n 'function',\r\n 'evalOrigin'\r\n];\r\n\r\nconst boolProperties = [\r\n 'topLevel',\r\n 'eval',\r\n 'native',\r\n 'constructor'\r\n];\r\n\r\nstrProperties.forEach(function (property) {\r\n CallSite.prototype[property] = null;\r\n CallSite.prototype['get' + property[0].toUpperCase() + property.substr(1)] = function () {\r\n return this[property];\r\n }\r\n});\r\n\r\nboolProperties.forEach(function (property) {\r\n CallSite.prototype[property] = false;\r\n CallSite.prototype['is' + property[0].toUpperCase() + property.substr(1)] = function () {\r\n return this[property];\r\n }\r\n});\r\n\r\nfunction createParsedCallSite(properties) {\r\n return new CallSite(properties);\r\n}\r\n","import {\n Measurement,\n optimizeFunction,\n setupCore,\n teardownCore,\n} from \"@codspeed/core\";\nimport { findUpSync, Options } from \"find-up\";\nimport path, { dirname } from \"path\";\nimport { get as getStackTrace } from \"stack-trace\";\nimport { Bench, Task } from \"tinybench\";\nimport { fileURLToPath } from \"url\";\n\ndeclare const __VERSION__: string;\n\ntype CodSpeedBenchOptions = Task[\"opts\"] & {\n uri: string;\n};\n\nfunction isCodSpeedBenchOptions(\n options: Task[\"opts\"]\n): options is CodSpeedBenchOptions {\n return \"uri\" in options;\n}\n\nexport function withCodSpeed(bench: Bench): Bench {\n if (!Measurement.isInstrumented()) {\n const rawRun = bench.run;\n bench.run = async () => {\n console.warn(\n `[CodSpeed] ${bench.tasks.length} benches detected but no instrumentation found, falling back to tinybench`\n );\n return await rawRun.bind(bench)();\n };\n return bench;\n }\n\n const rawAdd = bench.add;\n bench.add = (name, fn, opts: CodSpeedBenchOptions) => {\n const callingFile = getCallingFile();\n const uri = `${callingFile}::${name}`;\n const options = Object.assign({}, opts ?? {}, { uri });\n return rawAdd.bind(bench)(name, fn, options);\n };\n const rootCallingFile = getCallingFile();\n\n bench.run = async () => {\n console.log(`[CodSpeed] running with @codspeed/tinybench v${__VERSION__}`);\n setupCore();\n for (const task of bench.tasks) {\n const uri = isCodSpeedBenchOptions(task.opts)\n ? task.opts.uri\n : `${rootCallingFile}::${task.name}`;\n\n await task.opts.beforeAll?.call(task);\n\n // run optimizations\n await optimizeFunction(async () => {\n await task.opts.beforeEach?.call(task);\n await task.fn();\n await task.opts.afterEach?.call(task);\n });\n\n // run instrumented benchmark\n await task.opts.beforeEach?.call(task);\n await (async function __codspeed_root_frame__() {\n Measurement.startInstrumentation();\n await task.fn();\n Measurement.stopInstrumentation(uri);\n })();\n await task.opts.afterEach?.call(task);\n\n await task.opts.afterAll?.call(task);\n\n // print results\n console.log(` ✔ Measured ${uri}`);\n }\n teardownCore();\n console.log(`[CodSpeed] Done running ${bench.tasks.length} benches.`);\n return bench.tasks;\n };\n return bench;\n}\n\nfunction getCallingFile(): string {\n const stack = getStackTrace();\n let callingFile = stack[2].getFileName(); // [here, withCodSpeed, actual caller]\n const gitDir = getGitDir(callingFile);\n if (gitDir === undefined) {\n throw new Error(\"Could not find a git repository\");\n }\n if (callingFile.startsWith(\"file://\")) {\n callingFile = fileURLToPath(callingFile);\n }\n return path.relative(gitDir, callingFile);\n}\n\nfunction getGitDir(path: string): string | undefined {\n const dotGitPath = findUpSync(\".git\", {\n cwd: path,\n type: \"directory\",\n } as Options);\n return dotGitPath ? dirname(dotGitPath) : undefined;\n}\n"],"names":["toPath","fileURLToPath","Measurement","setupCore","optimizeFunction","_a","_b","teardownCore","getStackTrace","path","dirname"],"mappings":";;;;;;;;;;AAMA,MAAM,YAAY,GAAG;AACrB,CAAC,SAAS,EAAE,aAAa;AACzB,CAAC,IAAI,EAAE,QAAQ;AACf,CAAC,CAAC;AACF;AACA,SAAS,SAAS,CAAC,IAAI,EAAE;AACzB,CAAC,IAAI,MAAM,CAAC,cAAc,CA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,MAAA,EAAQ,WAAW,CAAA,CAAA;AAC1C,CAAA;AAEA,SAAS,UAAUA,KAAkC,EAAA;AACnD,EAAM,MAAA,UAAA,GAAa,WAAW,MAAQ,EAAA;AAAA,IACpC,GAAKA,EAAAA,KAAAA;AAAA,IACL,IAAM,EAAA,WAAA;AAAA,GACI,CAAA,CAAA;AACZ,EAAO,OAAA,UAAA,GAAaC,cAAQ,CAAA,UAAU,CAAI,GAAA,KAAA,CAAA,CAAA;AAC5C;;;;","x_google_ignoreList":[0,1,2]}
1
+ {"version":3,"file":"index.cjs.js","sources":["../../../node_modules/.pnpm/stack-trace@1.0.0-pre2/node_modules/stack-trace/index.js","../src/index.ts"],"sourcesContent":["export function get(belowFn) {\r\n const oldLimit = Error.stackTraceLimit;\r\n Error.stackTraceLimit = Infinity;\r\n\r\n const dummyObject = {};\r\n\r\n const v8Handler = Error.prepareStackTrace;\r\n Error.prepareStackTrace = function(dummyObject, v8StackTrace) {\r\n return v8StackTrace;\r\n };\r\n Error.captureStackTrace(dummyObject, belowFn || get);\r\n\r\n const v8StackTrace = dummyObject.stack;\r\n Error.prepareStackTrace = v8Handler;\r\n Error.stackTraceLimit = oldLimit;\r\n\r\n return v8StackTrace;\r\n}\r\n\r\nexport function parse(err) {\r\n if (!err.stack) {\r\n return [];\r\n }\r\n\r\n const lines = err.stack.split('\\n').slice(1);\r\n return lines\r\n .map(function(line) {\r\n if (line.match(/^\\s*[-]{4,}$/)) {\r\n return createParsedCallSite({\r\n fileName: line,\r\n lineNumber: null,\r\n functionName: null,\r\n typeName: null,\r\n methodName: null,\r\n columnNumber: null,\r\n 'native': null,\r\n });\r\n }\r\n\r\n const lineMatch = line.match(/at (?:(.+?)\\s+\\()?(?:(.+?):(\\d+)(?::(\\d+))?|([^)]+))\\)?/);\r\n if (!lineMatch) {\r\n return;\r\n }\r\n\r\n let object = null;\r\n let method = null;\r\n let functionName = null;\r\n let typeName = null;\r\n let methodName = null;\r\n let isNative = (lineMatch[5] === 'native');\r\n\r\n if (lineMatch[1]) {\r\n functionName = lineMatch[1];\r\n let methodStart = functionName.lastIndexOf('.');\r\n if (functionName[methodStart-1] == '.')\r\n methodStart--;\r\n if (methodStart > 0) {\r\n object = functionName.substr(0, methodStart);\r\n method = functionName.substr(methodStart + 1);\r\n const objectEnd = object.indexOf('.Module');\r\n if (objectEnd > 0) {\r\n functionName = functionName.substr(objectEnd + 1);\r\n object = object.substr(0, objectEnd);\r\n }\r\n }\r\n }\r\n\r\n if (method) {\r\n typeName = object;\r\n methodName = method;\r\n }\r\n\r\n if (method === '<anonymous>') {\r\n methodName = null;\r\n functionName = null;\r\n }\r\n\r\n const properties = {\r\n fileName: lineMatch[2] || null,\r\n lineNumber: parseInt(lineMatch[3], 10) || null,\r\n functionName: functionName,\r\n typeName: typeName,\r\n methodName: methodName,\r\n columnNumber: parseInt(lineMatch[4], 10) || null,\r\n 'native': isNative,\r\n };\r\n\r\n return createParsedCallSite(properties);\r\n })\r\n .filter(function(callSite) {\r\n return !!callSite;\r\n });\r\n}\r\n\r\nfunction CallSite(properties) {\r\n for (const property in properties) {\r\n this[property] = properties[property];\r\n }\r\n}\r\n\r\nconst strProperties = [\r\n 'this',\r\n 'typeName',\r\n 'functionName',\r\n 'methodName',\r\n 'fileName',\r\n 'lineNumber',\r\n 'columnNumber',\r\n 'function',\r\n 'evalOrigin'\r\n];\r\n\r\nconst boolProperties = [\r\n 'topLevel',\r\n 'eval',\r\n 'native',\r\n 'constructor'\r\n];\r\n\r\nstrProperties.forEach(function (property) {\r\n CallSite.prototype[property] = null;\r\n CallSite.prototype['get' + property[0].toUpperCase() + property.substr(1)] = function () {\r\n return this[property];\r\n }\r\n});\r\n\r\nboolProperties.forEach(function (property) {\r\n CallSite.prototype[property] = false;\r\n CallSite.prototype['is' + property[0].toUpperCase() + property.substr(1)] = function () {\r\n return this[property];\r\n }\r\n});\r\n\r\nfunction createParsedCallSite(properties) {\r\n return new CallSite(properties);\r\n}\r\n","import {\n getGitDir,\n Measurement,\n optimizeFunction,\n setupCore,\n teardownCore,\n tryIntrospect,\n} from \"@codspeed/core\";\nimport path from \"path\";\nimport { get as getStackTrace } from \"stack-trace\";\nimport { Bench, Task } from \"tinybench\";\nimport { fileURLToPath } from \"url\";\n\ndeclare const __VERSION__: string;\n\ntryIntrospect();\n\ntype CodSpeedBenchOptions = Task[\"opts\"] & {\n uri: string;\n};\n\nfunction isCodSpeedBenchOptions(\n options: Task[\"opts\"]\n): options is CodSpeedBenchOptions {\n return \"uri\" in options;\n}\n\nexport function withCodSpeed(bench: Bench): Bench {\n if (!Measurement.isInstrumented()) {\n const rawRun = bench.run;\n bench.run = async () => {\n console.warn(\n `[CodSpeed] ${bench.tasks.length} benches detected but no instrumentation found, falling back to tinybench`\n );\n return await rawRun.bind(bench)();\n };\n return bench;\n }\n\n const rawAdd = bench.add;\n bench.add = (name, fn, opts: CodSpeedBenchOptions) => {\n const callingFile = getCallingFile();\n const uri = `${callingFile}::${name}`;\n const options = Object.assign({}, opts ?? {}, { uri });\n return rawAdd.bind(bench)(name, fn, options);\n };\n const rootCallingFile = getCallingFile();\n\n bench.run = async () => {\n console.log(`[CodSpeed] running with @codspeed/tinybench v${__VERSION__}`);\n setupCore();\n for (const task of bench.tasks) {\n const uri = isCodSpeedBenchOptions(task.opts)\n ? task.opts.uri\n : `${rootCallingFile}::${task.name}`;\n\n await task.opts.beforeAll?.call(task);\n\n // run optimizations\n await optimizeFunction(async () => {\n await task.opts.beforeEach?.call(task);\n await task.fn();\n await task.opts.afterEach?.call(task);\n });\n\n // run instrumented benchmark\n await task.opts.beforeEach?.call(task);\n await (async function __codspeed_root_frame__() {\n Measurement.startInstrumentation();\n await task.fn();\n Measurement.stopInstrumentation(uri);\n })();\n await task.opts.afterEach?.call(task);\n\n await task.opts.afterAll?.call(task);\n\n // print results\n console.log(` ✔ Measured ${uri}`);\n }\n teardownCore();\n console.log(`[CodSpeed] Done running ${bench.tasks.length} benches.`);\n return bench.tasks;\n };\n return bench;\n}\n\nfunction getCallingFile(): string {\n const stack = getStackTrace();\n let callingFile = stack[2].getFileName(); // [here, withCodSpeed, actual caller]\n const gitDir = getGitDir(callingFile);\n if (gitDir === undefined) {\n throw new Error(\"Could not find a git repository\");\n }\n if (callingFile.startsWith(\"file://\")) {\n callingFile = fileURLToPath(callingFile);\n }\n return path.relative(gitDir, callingFile);\n}\n"],"names":["tryIntrospect","Measurement","setupCore","optimizeFunction","teardownCore","getStackTrace","getGitDir","fileURLToPath"],"mappings":";;;;;;AAAO,SAAS,GAAG,CAAC,OAAO,EAAE;AAC7B,EAAE,MAAM,QAAQ,GAAG,KAAK,CAAC,eAAe,CAAC;AACzC,EAAE,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC;AACnC;AACA,EAAE,MAAM,WAAW,GAAG,EAAE,CAAC;AACzB;AACA,EAAE,MAAM,SAAS,GAAG,KAAK,CAAC,iBAAiB,CAAC;AAC5C,EAAE,KAAK,CAAC,iBAAiB,GAAG,SAAS,WAAW,EAAE,YAAY,EAAE;AAChE,IAAI,OAAO,YAAY,CAAC;AACxB,GAAG,CAAC;AACJ,EAAE,KAAK,CAAC,iBAAiB,CAAC,WAAW,EAAE,OAAO,IAAI,GAAG,CAAC,CAAC;AACvD;AACA,EAAE,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC;AACzC,EAAE,KAAK,CAAC,iBAAiB,GAAG,SAAS,CAAC;AACtC,EAAE,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC;AACnC;AACA,EAAE,OAAO,YAAY,CAAC;AACtB,CAAC;AA4ED;AACA,SAAS,QAAQ,CAAC,UAAU,EAAE;AAC9B,EAAE,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE;AACrC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC1C,GAAG;AACH,CAAC;AACD;AACA,MAAM,aAAa,GAAG;AACtB,EAAE,MAAM;AACR,EAAE,UAAU;AACZ,EAA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AAA;AACvC,EAAM,MAAA,MAAA,GAASC,eAAU,WAAW,CAAA,CAAA;AACpC,EAAA,IAAI,WAAW,KAAW,CAAA,EAAA;AACxB,IAAM,MAAA,IAAI,MAAM,iCAAiC,CAAA,CAAA;AAAA,GACnD;AACA,EAAI,IAAA,WAAA,CAAY,UAAW,CAAA,SAAS,CAAG,EAAA;AACrC,IAAA,WAAA,GAAcC,kBAAc,WAAW,CAAA,CAAA;AAAA,GACzC;AACA,EAAO,OAAA,IAAA,CAAK,QAAS,CAAA,MAAA,EAAQ,WAAW,CAAA,CAAA;AAC1C;;;;","x_google_ignoreList":[0]}
package/dist/index.es5.js CHANGED
@@ -1,109 +1,6 @@
1
- import { Measurement, setupCore, optimizeFunction, teardownCore } from '@codspeed/core';
2
- import path from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
- import process from 'node:process';
5
- import fs from 'node:fs';
6
- import path$1, { dirname } from 'path';
7
- import { fileURLToPath as fileURLToPath$1 } from 'url';
8
-
9
- const typeMappings = {
10
- directory: 'isDirectory',
11
- file: 'isFile',
12
- };
13
-
14
- function checkType(type) {
15
- if (Object.hasOwnProperty.call(typeMappings, type)) {
16
- return;
17
- }
18
-
19
- throw new Error(`Invalid type specified: ${type}`);
20
- }
21
-
22
- const matchType = (type, stat) => stat[typeMappings[type]]();
23
-
24
- const toPath$1 = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
25
-
26
- function locatePathSync(
27
- paths,
28
- {
29
- cwd = process.cwd(),
30
- type = 'file',
31
- allowSymlinks = true,
32
- } = {},
33
- ) {
34
- checkType(type);
35
- cwd = toPath$1(cwd);
36
-
37
- const statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;
38
-
39
- for (const path_ of paths) {
40
- try {
41
- const stat = statFunction(path.resolve(cwd, path_), {
42
- throwIfNoEntry: false,
43
- });
44
-
45
- if (!stat) {
46
- continue;
47
- }
48
-
49
- if (matchType(type, stat)) {
50
- return path_;
51
- }
52
- } catch {}
53
- }
54
- }
55
-
56
- const toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
57
-
58
- const findUpStop = Symbol('findUpStop');
59
-
60
- function findUpMultipleSync(name, options = {}) {
61
- let directory = path.resolve(toPath(options.cwd) || '');
62
- const {root} = path.parse(directory);
63
- const stopAt = options.stopAt || root;
64
- const limit = options.limit || Number.POSITIVE_INFINITY;
65
- const paths = [name].flat();
66
-
67
- const runMatcher = locateOptions => {
68
- if (typeof name !== 'function') {
69
- return locatePathSync(paths, locateOptions);
70
- }
71
-
72
- const foundPath = name(locateOptions.cwd);
73
- if (typeof foundPath === 'string') {
74
- return locatePathSync([foundPath], locateOptions);
75
- }
76
-
77
- return foundPath;
78
- };
79
-
80
- const matches = [];
81
- // eslint-disable-next-line no-constant-condition
82
- while (true) {
83
- const foundPath = runMatcher({...options, cwd: directory});
84
-
85
- if (foundPath === findUpStop) {
86
- break;
87
- }
88
-
89
- if (foundPath) {
90
- matches.push(path.resolve(directory, foundPath));
91
- }
92
-
93
- if (directory === stopAt || matches.length >= limit) {
94
- break;
95
- }
96
-
97
- directory = path.dirname(directory);
98
- }
99
-
100
- return matches;
101
- }
102
-
103
- function findUpSync(name, options = {}) {
104
- const matches = findUpMultipleSync(name, {...options, limit: 1});
105
- return matches[0];
106
- }
1
+ import { tryIntrospect, Measurement, setupCore, optimizeFunction, teardownCore, getGitDir } from '@codspeed/core';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
107
4
 
108
5
  function get(belowFn) {
109
6
  const oldLimit = Error.stackTraceLimit;
@@ -163,6 +60,7 @@ boolProperties.forEach(function (property) {
163
60
  };
164
61
  });
165
62
 
63
+ tryIntrospect();
166
64
  function isCodSpeedBenchOptions(options) {
167
65
  return "uri" in options;
168
66
  }
@@ -181,31 +79,29 @@ function withCodSpeed(bench) {
181
79
  bench.add = (name, fn, opts) => {
182
80
  const callingFile = getCallingFile();
183
81
  const uri = `${callingFile}::${name}`;
184
- const options = Object.assign({}, opts != null ? opts : {}, { uri });
82
+ const options = Object.assign({}, opts ?? {}, { uri });
185
83
  return rawAdd.bind(bench)(name, fn, options);
186
84
  };
187
85
  const rootCallingFile = getCallingFile();
188
86
  bench.run = async () => {
189
- var _a, _b, _c, _d;
190
- console.log(`[CodSpeed] running with @codspeed/tinybench v${"2.2.0"}`);
87
+ console.log(`[CodSpeed] running with @codspeed/tinybench v${"2.3.0"}`);
191
88
  setupCore();
192
89
  for (const task of bench.tasks) {
193
90
  const uri = isCodSpeedBenchOptions(task.opts) ? task.opts.uri : `${rootCallingFile}::${task.name}`;
194
- await ((_a = task.opts.beforeAll) == null ? void 0 : _a.call(task));
91
+ await task.opts.beforeAll?.call(task);
195
92
  await optimizeFunction(async () => {
196
- var _a2, _b2;
197
- await ((_a2 = task.opts.beforeEach) == null ? void 0 : _a2.call(task));
93
+ await task.opts.beforeEach?.call(task);
198
94
  await task.fn();
199
- await ((_b2 = task.opts.afterEach) == null ? void 0 : _b2.call(task));
95
+ await task.opts.afterEach?.call(task);
200
96
  });
201
- await ((_b = task.opts.beforeEach) == null ? void 0 : _b.call(task));
97
+ await task.opts.beforeEach?.call(task);
202
98
  await async function __codspeed_root_frame__() {
203
99
  Measurement.startInstrumentation();
204
100
  await task.fn();
205
101
  Measurement.stopInstrumentation(uri);
206
102
  }();
207
- await ((_c = task.opts.afterEach) == null ? void 0 : _c.call(task));
208
- await ((_d = task.opts.afterAll) == null ? void 0 : _d.call(task));
103
+ await task.opts.afterEach?.call(task);
104
+ await task.opts.afterAll?.call(task);
209
105
  console.log(` \u2714 Measured ${uri}`);
210
106
  }
211
107
  teardownCore();
@@ -222,16 +118,9 @@ function getCallingFile() {
222
118
  throw new Error("Could not find a git repository");
223
119
  }
224
120
  if (callingFile.startsWith("file://")) {
225
- callingFile = fileURLToPath$1(callingFile);
121
+ callingFile = fileURLToPath(callingFile);
226
122
  }
227
- return path$1.relative(gitDir, callingFile);
228
- }
229
- function getGitDir(path2) {
230
- const dotGitPath = findUpSync(".git", {
231
- cwd: path2,
232
- type: "directory"
233
- });
234
- return dotGitPath ? dirname(dotGitPath) : void 0;
123
+ return path.relative(gitDir, callingFile);
235
124
  }
236
125
 
237
126
  export { withCodSpeed };
@@ -1 +1 @@
1
- {"version":3,"file":"index.es5.js","sources":["../../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js","../../../node_modules/.pnpm/find-up@6.3.0/node_modules/find-up/index.js","../../../node_modules/.pnpm/stack-trace@1.0.0-pre2/node_modules/stack-trace/index.js","../src/index.ts"],"sourcesContent":["import process from 'node:process';\nimport path from 'node:path';\nimport fs, {promises as fsPromises} from 'node:fs';\nimport {fileURLToPath} from 'node:url';\nimport pLocate from 'p-locate';\n\nconst typeMappings = {\n\tdirectory: 'isDirectory',\n\tfile: 'isFile',\n};\n\nfunction checkType(type) {\n\tif (Object.hasOwnProperty.call(typeMappings, type)) {\n\t\treturn;\n\t}\n\n\tthrow new Error(`Invalid type specified: ${type}`);\n}\n\nconst matchType = (type, stat) => stat[typeMappings[type]]();\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport async function locatePath(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t\tconcurrency,\n\t\tpreserveOrder,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;\n\n\treturn pLocate(paths, async path_ => {\n\t\ttry {\n\t\t\tconst stat = await statFunction(path.resolve(cwd, path_));\n\t\t\treturn matchType(type, stat);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}, {concurrency, preserveOrder});\n}\n\nexport function locatePathSync(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;\n\n\tfor (const path_ of paths) {\n\t\ttry {\n\t\t\tconst stat = statFunction(path.resolve(cwd, path_), {\n\t\t\t\tthrowIfNoEntry: false,\n\t\t\t});\n\n\t\t\tif (!stat) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (matchType(type, stat)) {\n\t\t\t\treturn path_;\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n","import path from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {locatePath, locatePathSync} from 'locate-path';\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport const findUpStop = Symbol('findUpStop');\n\nexport async function findUpMultiple(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) || '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = path.resolve(directory, options.stopAt || root);\n\tconst limit = options.limit || Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = async locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePath(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = await name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePath([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tconst foundPath = await runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport function findUpMultipleSync(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) || '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = options.stopAt || root;\n\tconst limit = options.limit || Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePathSync(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePathSync([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\tconst foundPath = runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport async function findUp(name, options = {}) {\n\tconst matches = await findUpMultiple(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport function findUpSync(name, options = {}) {\n\tconst matches = findUpMultipleSync(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport {\n\tpathExists,\n\tpathExistsSync,\n} from 'path-exists';\n","export function get(belowFn) {\r\n const oldLimit = Error.stackTraceLimit;\r\n Error.stackTraceLimit = Infinity;\r\n\r\n const dummyObject = {};\r\n\r\n const v8Handler = Error.prepareStackTrace;\r\n Error.prepareStackTrace = function(dummyObject, v8StackTrace) {\r\n return v8StackTrace;\r\n };\r\n Error.captureStackTrace(dummyObject, belowFn || get);\r\n\r\n const v8StackTrace = dummyObject.stack;\r\n Error.prepareStackTrace = v8Handler;\r\n Error.stackTraceLimit = oldLimit;\r\n\r\n return v8StackTrace;\r\n}\r\n\r\nexport function parse(err) {\r\n if (!err.stack) {\r\n return [];\r\n }\r\n\r\n const lines = err.stack.split('\\n').slice(1);\r\n return lines\r\n .map(function(line) {\r\n if (line.match(/^\\s*[-]{4,}$/)) {\r\n return createParsedCallSite({\r\n fileName: line,\r\n lineNumber: null,\r\n functionName: null,\r\n typeName: null,\r\n methodName: null,\r\n columnNumber: null,\r\n 'native': null,\r\n });\r\n }\r\n\r\n const lineMatch = line.match(/at (?:(.+?)\\s+\\()?(?:(.+?):(\\d+)(?::(\\d+))?|([^)]+))\\)?/);\r\n if (!lineMatch) {\r\n return;\r\n }\r\n\r\n let object = null;\r\n let method = null;\r\n let functionName = null;\r\n let typeName = null;\r\n let methodName = null;\r\n let isNative = (lineMatch[5] === 'native');\r\n\r\n if (lineMatch[1]) {\r\n functionName = lineMatch[1];\r\n let methodStart = functionName.lastIndexOf('.');\r\n if (functionName[methodStart-1] == '.')\r\n methodStart--;\r\n if (methodStart > 0) {\r\n object = functionName.substr(0, methodStart);\r\n method = functionName.substr(methodStart + 1);\r\n const objectEnd = object.indexOf('.Module');\r\n if (objectEnd > 0) {\r\n functionName = functionName.substr(objectEnd + 1);\r\n object = object.substr(0, objectEnd);\r\n }\r\n }\r\n }\r\n\r\n if (method) {\r\n typeName = object;\r\n methodName = method;\r\n }\r\n\r\n if (method === '<anonymous>') {\r\n methodName = null;\r\n functionName = null;\r\n }\r\n\r\n const properties = {\r\n fileName: lineMatch[2] || null,\r\n lineNumber: parseInt(lineMatch[3], 10) || null,\r\n functionName: functionName,\r\n typeName: typeName,\r\n methodName: methodName,\r\n columnNumber: parseInt(lineMatch[4], 10) || null,\r\n 'native': isNative,\r\n };\r\n\r\n return createParsedCallSite(properties);\r\n })\r\n .filter(function(callSite) {\r\n return !!callSite;\r\n });\r\n}\r\n\r\nfunction CallSite(properties) {\r\n for (const property in properties) {\r\n this[property] = properties[property];\r\n }\r\n}\r\n\r\nconst strProperties = [\r\n 'this',\r\n 'typeName',\r\n 'functionName',\r\n 'methodName',\r\n 'fileName',\r\n 'lineNumber',\r\n 'columnNumber',\r\n 'function',\r\n 'evalOrigin'\r\n];\r\n\r\nconst boolProperties = [\r\n 'topLevel',\r\n 'eval',\r\n 'native',\r\n 'constructor'\r\n];\r\n\r\nstrProperties.forEach(function (property) {\r\n CallSite.prototype[property] = null;\r\n CallSite.prototype['get' + property[0].toUpperCase() + property.substr(1)] = function () {\r\n return this[property];\r\n }\r\n});\r\n\r\nboolProperties.forEach(function (property) {\r\n CallSite.prototype[property] = false;\r\n CallSite.prototype['is' + property[0].toUpperCase() + property.substr(1)] = function () {\r\n return this[property];\r\n }\r\n});\r\n\r\nfunction createParsedCallSite(properties) {\r\n return new CallSite(properties);\r\n}\r\n","import {\n Measurement,\n optimizeFunction,\n setupCore,\n teardownCore,\n} from \"@codspeed/core\";\nimport { findUpSync, Options } from \"find-up\";\nimport path, { dirname } from \"path\";\nimport { get as getStackTrace } from \"stack-trace\";\nimport { Bench, Task } from \"tinybench\";\nimport { fileURLToPath } from \"url\";\n\ndeclare const __VERSION__: string;\n\ntype CodSpeedBenchOptions = Task[\"opts\"] & {\n uri: string;\n};\n\nfunction isCodSpeedBenchOptions(\n options: Task[\"opts\"]\n): options is CodSpeedBenchOptions {\n return \"uri\" in options;\n}\n\nexport function withCodSpeed(bench: Bench): Bench {\n if (!Measurement.isInstrumented()) {\n const rawRun = bench.run;\n bench.run = async () => {\n console.warn(\n `[CodSpeed] ${bench.tasks.length} benches detected but no instrumentation found, falling back to tinybench`\n );\n return await rawRun.bind(bench)();\n };\n return bench;\n }\n\n const rawAdd = bench.add;\n bench.add = (name, fn, opts: CodSpeedBenchOptions) => {\n const callingFile = getCallingFile();\n const uri = `${callingFile}::${name}`;\n const options = Object.assign({}, opts ?? {}, { uri });\n return rawAdd.bind(bench)(name, fn, options);\n };\n const rootCallingFile = getCallingFile();\n\n bench.run = async () => {\n console.log(`[CodSpeed] running with @codspeed/tinybench v${__VERSION__}`);\n setupCore();\n for (const task of bench.tasks) {\n const uri = isCodSpeedBenchOptions(task.opts)\n ? task.opts.uri\n : `${rootCallingFile}::${task.name}`;\n\n await task.opts.beforeAll?.call(task);\n\n // run optimizations\n await optimizeFunction(async () => {\n await task.opts.beforeEach?.call(task);\n await task.fn();\n await task.opts.afterEach?.call(task);\n });\n\n // run instrumented benchmark\n await task.opts.beforeEach?.call(task);\n await (async function __codspeed_root_frame__() {\n Measurement.startInstrumentation();\n await task.fn();\n Measurement.stopInstrumentation(uri);\n })();\n await task.opts.afterEach?.call(task);\n\n await task.opts.afterAll?.call(task);\n\n // print results\n console.log(` ✔ Measured ${uri}`);\n }\n teardownCore();\n console.log(`[CodSpeed] Done running ${bench.tasks.length} benches.`);\n return bench.tasks;\n };\n return bench;\n}\n\nfunction getCallingFile(): string {\n const stack = getStackTrace();\n let callingFile = stack[2].getFileName(); // [here, withCodSpeed, actual caller]\n const gitDir = getGitDir(callingFile);\n if (gitDir === undefined) {\n throw new Error(\"Could not find a git repository\");\n }\n if (callingFile.startsWith(\"file://\")) {\n callingFile = fileURLToPath(callingFile);\n }\n return path.relative(gitDir, callingFile);\n}\n\nfunction getGitDir(path: string): string | undefined {\n const dotGitPath = findUpSync(\".git\", {\n cwd: path,\n type: \"directory\",\n } as Options);\n return dotGitPath ? dirname(dotGitPath) : undefined;\n}\n"],"names":["toPath","_a","_b","getStackTrace","fileURLToPath","path"],"mappings":";;;;;;;;AAMA,MAAM,YAAY,GAAG;AACrB,CAAC,SAAS,EAAE,aAAa;AACzB,CAAC,IAAI,EAAE,QAAQ;AACf,CAAC,CAAC;AACF;AACA,SAAS,SAAS,CAAC,IAAI,EAAE;AACzB,CAAC,IAAI,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE;AACrD,EAAE,OAAO;AACT,EAAE;AACF;AACA,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC;AACD;AACA,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC,YAAY,CAAC,IAA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CAAA,CAAA;AAC5C;;;;","x_google_ignoreList":[0,1,2]}
1
+ {"version":3,"file":"index.es5.js","sources":["../../../node_modules/.pnpm/stack-trace@1.0.0-pre2/node_modules/stack-trace/index.js","../src/index.ts"],"sourcesContent":["export function get(belowFn) {\r\n const oldLimit = Error.stackTraceLimit;\r\n Error.stackTraceLimit = Infinity;\r\n\r\n const dummyObject = {};\r\n\r\n const v8Handler = Error.prepareStackTrace;\r\n Error.prepareStackTrace = function(dummyObject, v8StackTrace) {\r\n return v8StackTrace;\r\n };\r\n Error.captureStackTrace(dummyObject, belowFn || get);\r\n\r\n const v8StackTrace = dummyObject.stack;\r\n Error.prepareStackTrace = v8Handler;\r\n Error.stackTraceLimit = oldLimit;\r\n\r\n return v8StackTrace;\r\n}\r\n\r\nexport function parse(err) {\r\n if (!err.stack) {\r\n return [];\r\n }\r\n\r\n const lines = err.stack.split('\\n').slice(1);\r\n return lines\r\n .map(function(line) {\r\n if (line.match(/^\\s*[-]{4,}$/)) {\r\n return createParsedCallSite({\r\n fileName: line,\r\n lineNumber: null,\r\n functionName: null,\r\n typeName: null,\r\n methodName: null,\r\n columnNumber: null,\r\n 'native': null,\r\n });\r\n }\r\n\r\n const lineMatch = line.match(/at (?:(.+?)\\s+\\()?(?:(.+?):(\\d+)(?::(\\d+))?|([^)]+))\\)?/);\r\n if (!lineMatch) {\r\n return;\r\n }\r\n\r\n let object = null;\r\n let method = null;\r\n let functionName = null;\r\n let typeName = null;\r\n let methodName = null;\r\n let isNative = (lineMatch[5] === 'native');\r\n\r\n if (lineMatch[1]) {\r\n functionName = lineMatch[1];\r\n let methodStart = functionName.lastIndexOf('.');\r\n if (functionName[methodStart-1] == '.')\r\n methodStart--;\r\n if (methodStart > 0) {\r\n object = functionName.substr(0, methodStart);\r\n method = functionName.substr(methodStart + 1);\r\n const objectEnd = object.indexOf('.Module');\r\n if (objectEnd > 0) {\r\n functionName = functionName.substr(objectEnd + 1);\r\n object = object.substr(0, objectEnd);\r\n }\r\n }\r\n }\r\n\r\n if (method) {\r\n typeName = object;\r\n methodName = method;\r\n }\r\n\r\n if (method === '<anonymous>') {\r\n methodName = null;\r\n functionName = null;\r\n }\r\n\r\n const properties = {\r\n fileName: lineMatch[2] || null,\r\n lineNumber: parseInt(lineMatch[3], 10) || null,\r\n functionName: functionName,\r\n typeName: typeName,\r\n methodName: methodName,\r\n columnNumber: parseInt(lineMatch[4], 10) || null,\r\n 'native': isNative,\r\n };\r\n\r\n return createParsedCallSite(properties);\r\n })\r\n .filter(function(callSite) {\r\n return !!callSite;\r\n });\r\n}\r\n\r\nfunction CallSite(properties) {\r\n for (const property in properties) {\r\n this[property] = properties[property];\r\n }\r\n}\r\n\r\nconst strProperties = [\r\n 'this',\r\n 'typeName',\r\n 'functionName',\r\n 'methodName',\r\n 'fileName',\r\n 'lineNumber',\r\n 'columnNumber',\r\n 'function',\r\n 'evalOrigin'\r\n];\r\n\r\nconst boolProperties = [\r\n 'topLevel',\r\n 'eval',\r\n 'native',\r\n 'constructor'\r\n];\r\n\r\nstrProperties.forEach(function (property) {\r\n CallSite.prototype[property] = null;\r\n CallSite.prototype['get' + property[0].toUpperCase() + property.substr(1)] = function () {\r\n return this[property];\r\n }\r\n});\r\n\r\nboolProperties.forEach(function (property) {\r\n CallSite.prototype[property] = false;\r\n CallSite.prototype['is' + property[0].toUpperCase() + property.substr(1)] = function () {\r\n return this[property];\r\n }\r\n});\r\n\r\nfunction createParsedCallSite(properties) {\r\n return new CallSite(properties);\r\n}\r\n","import {\n getGitDir,\n Measurement,\n optimizeFunction,\n setupCore,\n teardownCore,\n tryIntrospect,\n} from \"@codspeed/core\";\nimport path from \"path\";\nimport { get as getStackTrace } from \"stack-trace\";\nimport { Bench, Task } from \"tinybench\";\nimport { fileURLToPath } from \"url\";\n\ndeclare const __VERSION__: string;\n\ntryIntrospect();\n\ntype CodSpeedBenchOptions = Task[\"opts\"] & {\n uri: string;\n};\n\nfunction isCodSpeedBenchOptions(\n options: Task[\"opts\"]\n): options is CodSpeedBenchOptions {\n return \"uri\" in options;\n}\n\nexport function withCodSpeed(bench: Bench): Bench {\n if (!Measurement.isInstrumented()) {\n const rawRun = bench.run;\n bench.run = async () => {\n console.warn(\n `[CodSpeed] ${bench.tasks.length} benches detected but no instrumentation found, falling back to tinybench`\n );\n return await rawRun.bind(bench)();\n };\n return bench;\n }\n\n const rawAdd = bench.add;\n bench.add = (name, fn, opts: CodSpeedBenchOptions) => {\n const callingFile = getCallingFile();\n const uri = `${callingFile}::${name}`;\n const options = Object.assign({}, opts ?? {}, { uri });\n return rawAdd.bind(bench)(name, fn, options);\n };\n const rootCallingFile = getCallingFile();\n\n bench.run = async () => {\n console.log(`[CodSpeed] running with @codspeed/tinybench v${__VERSION__}`);\n setupCore();\n for (const task of bench.tasks) {\n const uri = isCodSpeedBenchOptions(task.opts)\n ? task.opts.uri\n : `${rootCallingFile}::${task.name}`;\n\n await task.opts.beforeAll?.call(task);\n\n // run optimizations\n await optimizeFunction(async () => {\n await task.opts.beforeEach?.call(task);\n await task.fn();\n await task.opts.afterEach?.call(task);\n });\n\n // run instrumented benchmark\n await task.opts.beforeEach?.call(task);\n await (async function __codspeed_root_frame__() {\n Measurement.startInstrumentation();\n await task.fn();\n Measurement.stopInstrumentation(uri);\n })();\n await task.opts.afterEach?.call(task);\n\n await task.opts.afterAll?.call(task);\n\n // print results\n console.log(` ✔ Measured ${uri}`);\n }\n teardownCore();\n console.log(`[CodSpeed] Done running ${bench.tasks.length} benches.`);\n return bench.tasks;\n };\n return bench;\n}\n\nfunction getCallingFile(): string {\n const stack = getStackTrace();\n let callingFile = stack[2].getFileName(); // [here, withCodSpeed, actual caller]\n const gitDir = getGitDir(callingFile);\n if (gitDir === undefined) {\n throw new Error(\"Could not find a git repository\");\n }\n if (callingFile.startsWith(\"file://\")) {\n callingFile = fileURLToPath(callingFile);\n }\n return path.relative(gitDir, callingFile);\n}\n"],"names":["getStackTrace"],"mappings":";;;;AAAO,SAAS,GAAG,CAAC,OAA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;AAC1C;;;;","x_google_ignoreList":[0]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codspeed/tinybench-plugin",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "tinybench compatibility layer for CodSpeed",
5
5
  "keywords": [
6
6
  "codspeed",
@@ -19,14 +19,12 @@
19
19
  "homepage": "https://codspeed.io",
20
20
  "license": "Apache-2.0",
21
21
  "devDependencies": {
22
- "@types/find-up": "^4.0.0",
23
22
  "@types/stack-trace": "^0.0.30",
24
23
  "jest-mock-extended": "^3.0.4",
25
24
  "tinybench": "^2.5.0"
26
25
  },
27
26
  "dependencies": {
28
- "@codspeed/core": "^2.2.0",
29
- "find-up": "^6.3.0",
27
+ "@codspeed/core": "^2.3.0",
30
28
  "stack-trace": "1.0.0-pre2"
31
29
  },
32
30
  "peerDependencies": {