mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Co-authored-by: Claude <claude@anthropic.ai> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com>
29 lines
683 B
JavaScript
29 lines
683 B
JavaScript
import { SourceMap } from "node:module";
|
|
import { readFileSync } from "node:fs";
|
|
import { bench, run } from "../runner.mjs";
|
|
const json = JSON.parse(readFileSync(process.argv.at(-1), "utf-8"));
|
|
|
|
bench("new SourceMap(json)", () => {
|
|
return new SourceMap(json);
|
|
});
|
|
|
|
const map = new SourceMap(json);
|
|
|
|
const toRotate = [];
|
|
for (let j = 0; j < 10000; j++) {
|
|
if (map.findEntry(0, j).generatedColumn) {
|
|
toRotate.push(j);
|
|
if (toRotate.length > 5) break;
|
|
}
|
|
}
|
|
let i = 0;
|
|
bench("findEntry (match)", () => {
|
|
return map.findEntry(0, toRotate[i++ % 3]).generatedColumn;
|
|
});
|
|
|
|
bench("findEntry (no match)", () => {
|
|
return map.findEntry(0, 9999).generatedColumn;
|
|
});
|
|
|
|
await run();
|