mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
26 lines
639 B
JavaScript
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();
|