Files
bun.sh/bench/snippets/path-relative.mjs
chloe caruso f17ce2b756 hmr fixes (#17239)
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2025-02-12 23:14:02 -08:00

26 lines
639 B
JavaScript

import { posix } from "path";
import { bench, run } from "../runner.mjs";
const pathConfigurations = [
["", ""],
[".", "."],
["/foo/bar", "/foo/bar"],
["/foo/bar/baz", "/foo/bar"],
["/foo/bar", "/foo/bar/baz"],
["/foo/bar/baz", "/foo/bar/qux"],
["/foo/bar/baz", "/foo/bar/baz/qux"],
["/foo/bar/baz", "/foo/bar/baz/qux/quux"],
["/", "/foo"],
["/foo", "/"],
["foo/bar/baz", "foo/bar/qux"],
["../foo/bar", "../foo/baz"],
];
pathConfigurations.forEach(([from, to]) => {
bench(`relative(${JSON.stringify(from)}, ${JSON.stringify(to)})`, () => {
globalThis.abc = posix.relative(from, to);
});
});
await run();