From 729d445b6885f69dd2c6355f38707bd42851c791 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 22 Jun 2022 23:21:48 -0700 Subject: change the directory structure --- bench/snippets/_fixture.txt | 1610 -------------------------- bench/snippets/buffer-read.js | 77 -- bench/snippets/buffer.js | 136 --- bench/snippets/callbacks-overhead.mjs | 78 -- bench/snippets/cat.bun.js | 5 - bench/snippets/cat.mjs | 6 - bench/snippets/cat.node.js | 4 - bench/snippets/concat.js | 66 -- bench/snippets/copy.bun.js | 4 - bench/snippets/copyfile.mjs | 3 - bench/snippets/escapeHTML.js | 122 -- bench/snippets/exists.js | 6 - bench/snippets/gzip.js | 20 - bench/snippets/gzip.node.mjs | 20 - bench/snippets/jsx-entity-decoding.jsx | 29 - bench/snippets/noop.js | 17 - bench/snippets/package.json | 12 - bench/snippets/realpath.mjs | 4 - bench/snippets/render.js | 4 - bench/snippets/scanner/bun.lockb | Bin 6186 -> 0 bytes bench/snippets/scanner/package.json | 6 - bench/snippets/scanner/remix-route.ts | 15 - bench/snippets/scanner/scan-imports-only.js | 15 - bench/snippets/scanner/scan.bun.js | 21 - bench/snippets/scanner/scan.node-esbuild.mjs | 42 - bench/snippets/transpiler.mjs | 58 - 26 files changed, 2380 deletions(-) delete mode 100644 bench/snippets/_fixture.txt delete mode 100644 bench/snippets/buffer-read.js delete mode 100644 bench/snippets/buffer.js delete mode 100644 bench/snippets/callbacks-overhead.mjs delete mode 100644 bench/snippets/cat.bun.js delete mode 100644 bench/snippets/cat.mjs delete mode 100644 bench/snippets/cat.node.js delete mode 100644 bench/snippets/concat.js delete mode 100644 bench/snippets/copy.bun.js delete mode 100644 bench/snippets/copyfile.mjs delete mode 100644 bench/snippets/escapeHTML.js delete mode 100644 bench/snippets/exists.js delete mode 100644 bench/snippets/gzip.js delete mode 100644 bench/snippets/gzip.node.mjs delete mode 100644 bench/snippets/jsx-entity-decoding.jsx delete mode 100644 bench/snippets/noop.js delete mode 100644 bench/snippets/package.json delete mode 100644 bench/snippets/realpath.mjs delete mode 100644 bench/snippets/render.js delete mode 100755 bench/snippets/scanner/bun.lockb delete mode 100644 bench/snippets/scanner/package.json delete mode 100644 bench/snippets/scanner/remix-route.ts delete mode 100644 bench/snippets/scanner/scan-imports-only.js delete mode 100644 bench/snippets/scanner/scan.bun.js delete mode 100644 bench/snippets/scanner/scan.node-esbuild.mjs delete mode 100644 bench/snippets/transpiler.mjs (limited to 'bench/snippets') diff --git a/bench/snippets/_fixture.txt b/bench/snippets/_fixture.txt deleted file mode 100644 index d3c9bff5e..000000000 --- a/bench/snippets/_fixture.txt +++ /dev/null @@ -1,1610 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - v_escape/lib.rs at master · botika/v_escape · GitHub - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Skip to content - - - - - - - - - -
- -
- - - - -
- - - -
- - - - - - - - -
-
-
- - - - - - - - - - - - - - - -
-
- - - - - - - Permalink - - - - - -
- -
-
- - - master - - - - -
- - - -
-
-
- -
- - - - Go to file - - -
- - - - - - - -
- - - -
- -
-
-
 
-
- -
-
 
- Cannot retrieve contributors at this time -
-
- - - - - - -
- -
-
- - 168 lines (163 sloc) - - 10.7 KB -
- -
- -
- Raw - Blame -
- - -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
use v_htmlescape::HTMLEscape;
-
#[test]
fn test_escape() {
let empty = "";
let escapes = "<>&\"'/";
let escaped = "&lt;&gt;&amp;&quot;&#x27;&#x2f;";
let string_long: &str = &"foobar".repeat(1024);
-
// https://gitlab.com/r-iendo/v_escape/issues/2
let issue = "<".repeat(31);
assert_eq!(
HTMLEscape::from(issue.as_ref()).to_string(),
"&lt;".repeat(31)
);
-
assert_eq!(HTMLEscape::from(empty).to_string(), empty);
assert_eq!(HTMLEscape::from("").to_string(), "");
assert_eq!(HTMLEscape::from("<&>").to_string(), "&lt;&amp;&gt;");
assert_eq!(HTMLEscape::from("bar&").to_string(), "bar&amp;");
assert_eq!(HTMLEscape::from("<foo").to_string(), "&lt;foo");
assert_eq!(HTMLEscape::from("bar&h").to_string(), "bar&amp;h");
assert_eq!(
HTMLEscape::from("// my <html> is \"unsafe\" & should be 'escaped'").to_string(),
"&#x2f;&#x2f; my &lt;html&gt; is &quot;unsafe&quot; &amp; \
should be &#x27;escaped&#x27;"
);
assert_eq!(
HTMLEscape::from("<".repeat(16).as_ref()).to_string(),
"&lt;".repeat(16)
);
assert_eq!(
HTMLEscape::from("<".repeat(32).as_ref()).to_string(),
"&lt;".repeat(32)
);
assert_eq!(
HTMLEscape::from("<".repeat(64).as_ref()).to_string(),
"&lt;".repeat(64)
);
assert_eq!(
HTMLEscape::from("<".repeat(128).as_ref()).to_string(),
"&lt;".repeat(128)
);
assert_eq!(
HTMLEscape::from("<".repeat(1024).as_ref()).to_string(),
"&lt;".repeat(1024)
);
assert_eq!(
HTMLEscape::from("<".repeat(129).as_ref()).to_string(),
"&lt;".repeat(129)
);
assert_eq!(
HTMLEscape::from("<".repeat(128 * 2 - 1).as_ref()).to_string(),
"&lt;".repeat(128 * 2 - 1)
);
assert_eq!(
HTMLEscape::from("<".repeat(128 * 8 - 1).as_ref()).to_string(),
"&lt;".repeat(128 * 8 - 1)
);
assert_eq!(HTMLEscape::from(string_long).to_string(), string_long);
assert_eq!(
HTMLEscape::from([string_long, "<"].join("").as_ref()).to_string(),
[string_long, "&lt;"].join("")
);
assert_eq!(
HTMLEscape::from(["<", string_long].join("").as_ref()).to_string(),
["&lt;", string_long].join("")
);
assert_eq!(
HTMLEscape::from(escapes.repeat(1024).as_ref()).to_string(),
escaped.repeat(1024)
);
assert_eq!(
HTMLEscape::from(
[string_long, &escapes.repeat(13)]
.join("")
.repeat(1024)
.as_ref()
)
.to_string(),
[string_long, &escaped.repeat(13)].join("").repeat(1024)
);
assert_eq!(
HTMLEscape::from([string_long, "<", string_long].join("").as_ref()).to_string(),
[string_long, "&lt;", string_long].join("")
);
assert_eq!(
HTMLEscape::from(
[string_long, "<", string_long, escapes, string_long,]
.join("")
.as_ref()
)
.to_string(),
[string_long, "&lt;", string_long, escaped, string_long,].join("")
);
-
let string_long = r#"
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris consequat tellus sit
amet ornare fermentum. Etiam nec erat ante. In at metus a orci mollis scelerisque.
Sed eget ultrices turpis, at sollicitudin erat. Integer hendrerit nec magna quis
venenatis. Vivamus non dolor hendrerit, vulputate velit sed, varius nunc. Quisque
in pharetra mi. Sed ullamcorper nibh malesuada commodo porttitor. Ut scelerisque
sodales felis quis dignissim. Morbi aliquam finibus justo, sit amet consectetur
mauris efficitur sit amet. Donec posuere turpis felis, eu lacinia magna accumsan
quis. Fusce egestas lacus vel fermentum tincidunt. Phasellus a nulla eget lectus
placerat commodo at eget nisl. Fusce cursus dui quis purus accumsan auctor.
Donec iaculis felis quis metus consectetur porttitor.
<p>
Etiam nibh mi, <b>accumsan</b> quis purus sed, posuere fermentum lorem. In pulvinar porta
maximus. Fusce tincidunt lacinia tellus sit amet tincidunt. Aliquam lacus est, pulvinar
non metus a, <b>facilisis</b> ultrices quam. Nulla feugiat leo in cursus eleifend. Suspendisse
eget nisi ac justo sagittis interdum id a ipsum. Nulla mauris justo, scelerisque ac
rutrum vitae, consequat vel ex.
</p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p>
<p>
Sed sollicitudin <b>sem</b> mauris, at rutrum nibh egestas vel. Ut eu nisi tellus. Praesent dignissim
orci elementum, mattis turpis eget, maximus ante. Suspendisse luctus eu felis a tempor. Morbi
ac risus vitae sem molestie ullamcorper. Curabitur ligula augue, sollicitudin quis maximus vel,
facilisis sed nibh. Aenean auctor magna sem, id rutrum metus convallis quis. Nullam non arcu
dictum, lobortis erat quis, rhoncus est. Suspendisse venenatis, mi sed venenatis vehicula,
tortor dolor egestas lectus, et efficitur turpis odio non augue. Integer velit sapien, dictum
non egestas vitae, hendrerit sed quam. Phasellus a nunc eu erat varius imperdiet. Etiam id
sollicitudin turpis, vitae molestie orci. Quisque ornare magna quis metus rhoncus commodo.
Phasellus non mauris velit.
</p>
<p>
Etiam dictum tellus ipsum, nec varius quam ornare vel. Cras vehicula diam nec sollicitudin
ultricies. Pellentesque rhoncus sagittis nisl id facilisis. Nunc viverra convallis risus ut
luctus. Aliquam vestibulum <b>efficitur massa</b>, id tempus nisi posuere a. Aliquam scelerisque
elit justo. Nullam a ante felis. Cras vitae lorem eu nisi feugiat hendrerit. Maecenas vitae
suscipit leo, lacinia dignissim lacus. Sed eget volutpat mi. In eu bibendum neque. Pellentesque
finibus velit a fermentum rhoncus. Maecenas leo purus, eleifend eu lacus a, condimentum sagittis
justo.
</p>"#;
let string_long_escaped = "\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris consequat tellus sit\n amet ornare fermentum. Etiam nec erat ante. In at metus a orci mollis scelerisque.\n Sed eget ultrices turpis, at sollicitudin erat. Integer hendrerit nec magna quis\n venenatis. Vivamus non dolor hendrerit, vulputate velit sed, varius nunc. Quisque\n in pharetra mi. Sed ullamcorper nibh malesuada commodo porttitor. Ut scelerisque\n sodales felis quis dignissim. Morbi aliquam finibus justo, sit amet consectetur\n mauris efficitur sit amet. Donec posuere turpis felis, eu lacinia magna accumsan\n quis. Fusce egestas lacus vel fermentum tincidunt. Phasellus a nulla eget lectus\n placerat commodo at eget nisl. Fusce cursus dui quis purus accumsan auctor.\n Donec iaculis felis quis metus consectetur porttitor.\n&lt;p&gt;\n Etiam nibh mi, &lt;b&gt;accumsan&lt;&#x2f;b&gt; quis purus sed, posuere fermentum lorem. In pulvinar porta\n maximus. Fusce tincidunt lacinia tellus sit amet tincidunt. Aliquam lacus est, pulvinar\n non metus a, &lt;b&gt;facilisis&lt;&#x2f;b&gt; ultrices quam. Nulla feugiat leo in cursus eleifend. Suspendisse\n eget nisi ac justo sagittis interdum id a ipsum. Nulla mauris justo, scelerisque ac\n rutrum vitae, consequat vel ex.\n&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;&lt;&#x2f;p&gt;\n&lt;p&gt;\n Sed sollicitudin &lt;b&gt;sem&lt;&#x2f;b&gt; mauris, at rutrum nibh egestas vel. Ut eu nisi tellus. Praesent dignissim\n orci elementum, mattis turpis eget, maximus ante. Suspendisse luctus eu felis a tempor. Morbi\n ac risus vitae sem molestie ullamcorper. Curabitur ligula augue, sollicitudin quis maximus vel,\n facilisis sed nibh. Aenean auctor magna sem, id rutrum metus convallis quis. Nullam non arcu\n dictum, lobortis erat quis, rhoncus est. Suspendisse venenatis, mi sed venenatis vehicula,\n tortor dolor egestas lectus, et efficitur turpis odio non augue. Integer velit sapien, dictum\n non egestas vitae, hendrerit sed quam. Phasellus a nunc eu erat varius imperdiet. Etiam id\n sollicitudin turpis, vitae molestie orci. Quisque ornare magna quis metus rhoncus commodo.\n Phasellus non mauris velit.\n&lt;&#x2f;p&gt;\n&lt;p&gt;\n Etiam dictum tellus ipsum, nec varius quam ornare vel. Cras vehicula diam nec sollicitudin\n ultricies. Pellentesque rhoncus sagittis nisl id facilisis. Nunc viverra convallis risus ut\n luctus. Aliquam vestibulum &lt;b&gt;efficitur massa&lt;&#x2f;b&gt;, id tempus nisi posuere a. Aliquam scelerisque\n elit justo. Nullam a ante felis. Cras vitae lorem eu nisi feugiat hendrerit. Maecenas vitae\n suscipit leo, lacinia dignissim lacus. Sed eget volutpat mi. In eu bibendum neque. Pellentesque\n finibus velit a fermentum rhoncus. Maecenas leo purus, eleifend eu lacus a, condimentum sagittis\n justo.\n&lt;&#x2f;p&gt;";
let string_short = "Lorem ipsum dolor sit amet,<foo>bar&foo\"bar\\foo/bar";
let string_short_escaped =
"Lorem ipsum dolor sit amet,&lt;foo&gt;bar&amp;foo&quot;bar\\foo&#x2f;bar";
let no_escape = "Lorem ipsum dolor sit amet,";
let no_escape_long = r#"
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin scelerisque eu urna in aliquet.
Phasellus ac nulla a urna sagittis consequat id quis est. Nullam eu ex eget erat accumsan dictum
ac lobortis urna. Etiam fermentum ut quam at dignissim. Curabitur vestibulum luctus tellus, sit
amet lobortis augue tempor faucibus. Nullam sed felis eget odio elementum euismod in sit amet massa.
Vestibulum sagittis purus sit amet eros auctor, sit amet pharetra purus dapibus. Donec ornare metus
vel dictum porta. Etiam ut nisl nisi. Nullam rutrum porttitor mi. Donec aliquam ac ipsum eget
hendrerit. Cras faucibus, eros ut pharetra imperdiet, est tellus aliquet felis, eget convallis
lacus ipsum eget quam. Vivamus orci lorem, maximus ac mi eget, bibendum vulputate massa. In
vestibulum dui hendrerit, vestibulum lacus sit amet, posuere erat. Vivamus euismod massa diam,
vulputate euismod lectus vestibulum nec. Donec sit amet massa magna. Nunc ipsum nulla, euismod
quis lacus at, gravida maximus elit. Duis tristique, nisl nullam.
"#;
-
assert_eq!(HTMLEscape::from(no_escape).to_string(), no_escape);
assert_eq!(HTMLEscape::from(no_escape_long).to_string(), no_escape_long);
assert_eq!(
HTMLEscape::from(string_short).to_string(),
string_short_escaped
);
assert_eq!(
HTMLEscape::from(string_short.repeat(1024).as_ref()).to_string(),
string_short_escaped.repeat(1024)
);
assert_eq!(
HTMLEscape::from(string_long).to_string(),
string_long_escaped
);
}
- - - -
- -
- - - - -
- - -
- - -
-
- - - - -
-
- -
-
- -
- - - - - - -
- - - You can’t perform that action at this time. -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bench/snippets/buffer-read.js b/bench/snippets/buffer-read.js deleted file mode 100644 index 314f1d69e..000000000 --- a/bench/snippets/buffer-read.js +++ /dev/null @@ -1,77 +0,0 @@ -// import { Buffer } from "buffer"; -var buf = new Buffer(1024); -// var buf = new Uint8Array(1024); -var view = new DataView(buf.buffer); -var INTERVAL = 9999999; -var time = (name, fn) => { - for (let i = 0; i < INTERVAL; i++) fn(); - - console.time(name.padEnd("DataView.readBigUInt64 (LE)".length)); - for (let i = 0; i < INTERVAL; i++) fn(); - console.timeEnd(name.padEnd("DataView.readBigUInt64 (LE)".length)); -}; - -console.log( - `Run ${new Intl.NumberFormat().format(INTERVAL)} times with a warmup:`, - "\n" -); -var array = new Uint8Array(1024); -time("Buffer[] ", () => buf[0]); -time("Uint8Array[]", () => array[0]); -console.log(""); - -time("Buffer.getBigInt64BE ", () => buf.readBigInt64BE(0)); -time("DataView.getBigInt64 (BE)", () => view.getBigInt64(0, false)); -console.log(""); - -time("Buffer.readBigInt64LE ", () => buf.readBigInt64LE(0)); -time("DataView.readBigInt64 (LE)", () => view.getBigInt64(0, true)); -console.log(""); -time("Buffer.getBigUInt64BE ", () => buf.readBigUInt64BE(0)); -time("DataView.getBigUInt64 (BE)", () => view.getBigUint64(0, false)); -console.log(""); -time("Buffer.readBigUInt64LE ", () => buf.readBigUInt64LE(0)); -time("DataView.readBigUInt64 (LE)", () => view.getBigUint64(0, true)); -console.log(""); -time("Buffer.getDoubleBE ", () => buf.readDoubleBE(0)); -time("DataView.getDouble (BE)", () => view.getFloat64(0, false)); -console.log(""); -time("Buffer.readDoubleLE ", () => buf.readDoubleLE(0)); -time("DataView.readDouble (LE)", () => view.getFloat64(0, true)); -console.log(""); -time("Buffer.getFloatBE ", () => buf.readFloatBE(0)); -time("DataView.getFloat (BE)", () => view.getFloat32(0, false)); -console.log(""); -time("Buffer.readFloatLE ", () => buf.readFloatLE(0)); -time("DataView.readFloat (LE)", () => view.getFloat32(0, true)); -console.log(""); -time("Buffer.getInt16BE ", () => buf.readInt16BE(0)); -time("DataView.getInt16 (BE)", () => view.getInt16(0, false)); -console.log(""); -time("Buffer.readInt16LE ", () => buf.readInt16LE(0)); -time("DataView.readInt16 (LE)", () => view.getInt16(0, true)); -console.log(""); -time("Buffer.getInt32BE ", () => buf.readInt32BE(0)); -time("DataView.getInt32 (BE)", () => view.getInt32(0, false)); -console.log(""); -time("Buffer.readInt32LE ", () => buf.readInt32LE(0)); -time("DataView.readInt32 (LE)", () => view.getInt32(0, true)); -console.log(""); -time("Buffer.readInt8 ", () => buf.readInt8(0)); -time("DataView.readInt (t8)", () => view.getInt8(0)); -console.log(""); -time("Buffer.getUInt16BE ", () => buf.readUInt16BE(0)); -time("DataView.getUInt16 (BE)", () => view.getUint16(0, false)); -console.log(""); -time("Buffer.readUInt16LE ", () => buf.readUInt16LE(0)); -time("DataView.readUInt16 (LE)", () => view.getUint16(0, true)); -console.log(""); -time("Buffer.getUInt32BE ", () => buf.readUInt32BE(0)); -time("DataView.getUInt32 (BE)", () => view.getUint32(0, false)); -console.log(""); -time("Buffer.readUInt32LE ", () => buf.readUInt32LE(0)); -time("DataView.getUInt32 (LE)", () => view.getUint32(0, true)); -console.log(""); -time("Buffer.readUInt8 ", () => buf.readUInt8(0)); -time("DataView.getUInt (t8)", () => view.getUint8(0)); -console.log(""); diff --git a/bench/snippets/buffer.js b/bench/snippets/buffer.js deleted file mode 100644 index 9ababbf35..000000000 --- a/bench/snippets/buffer.js +++ /dev/null @@ -1,136 +0,0 @@ -// import { Buffer } from "buffer"; -var buf = new Buffer(1024); -var view = new DataView(buf.buffer); -var INTERVAL = 9999999; -var time = (name, fn) => { - for (let i = 0; i < INTERVAL; i++) fn(); - - console.time(name.padEnd('Buffer.write(string, "latin1")'.length)); - for (let i = 0; i < INTERVAL; i++) fn(); - console.timeEnd(name.padEnd('Buffer.write(string, "latin1")'.length)); -}; - -console.log( - `Run ${new Intl.NumberFormat().format(INTERVAL)} times with a warmup:`, - "\n" -); - -const stringToWrite = "hellooooohellooooo"; - -time('Buffer.write(string, "utf8")', () => buf.write(stringToWrite, "utf8")); -time('Buffer.write(string, "ascii")', () => buf.write(stringToWrite, "ascii")); -time('Buffer.write(string, "latin1")', () => - buf.write(stringToWrite, "latin1") -); -time("Buffer.readBigInt64BE ", () => buf.readBigInt64BE(0)); -// time("DataView.getBigInt64 (BE)", () => view.getBigInt64(0, false)); -// console.log(""); -time("Buffer.readBigInt64LE ", () => buf.readBigInt64LE(0)); -// time("DataView.readBigInt64 (LE)", () => view.getBigInt64(0, true)); -// console.log(""); -time("Buffer.readBigUInt64BE ", () => buf.readBigUInt64BE(0)); -// time("DataView.getBigUInt64 (BE)", () => view.getBigUint64(0, false)); -// console.log(""); -time("Buffer.readBigUInt64LE ", () => buf.readBigUInt64LE(0)); -// time("DataView.readBigUInt64 (LE)", () => view.getBigUint64(0, true)); -// console.log(""); -time("Buffer.readDoubleBE ", () => buf.readDoubleBE(0)); -// time("DataView.getDouble (BE)", () => view.getFloat64(0, false)); -// console.log(""); -time("Buffer.readDoubleLE ", () => buf.readDoubleLE(0)); -// time("DataView.readDouble (LE)", () => view.getFloat64(0, true)); -// console.log(""); -time("Buffer.readFloatBE ", () => buf.readFloatBE(0)); -// time("DataView.getFloat (BE)", () => view.getFloat32(0, false)); -// console.log(""); -time("Buffer.readFloatLE ", () => buf.readFloatLE(0)); -// time("DataView.readFloat (LE)", () => view.getFloat32(0, true)); -// console.log(""); -time("Buffer.readInt16BE ", () => buf.readInt16BE(0)); -// time("DataView.getInt16 (BE)", () => view.getInt16(0, false)); -// console.log(""); -time("Buffer.readInt16LE ", () => buf.readInt16LE(0)); -// time("DataView.readInt16 (LE)", () => view.getInt16(0, true)); -// console.log(""); -time("Buffer.readInt32BE ", () => buf.readInt32BE(0)); -// time("DataView.getInt32 (BE)", () => view.getInt32(0, false)); -// console.log(""); -time("Buffer.readInt32LE ", () => buf.readInt32LE(0)); -// time("DataView.readInt32 (LE)", () => view.getInt32(0, true)); -// console.log(""); -time("Buffer.readInt8 ", () => buf.readInt8(0)); -// time("DataView.readInt (t8)", () => view.getInt8(0)); -// console.log(""); -time("Buffer.readUInt16BE ", () => buf.readUInt16BE(0)); -// time("DataView.getUInt16 (BE)", () => view.getUint16(0, false)); -// console.log(""); -time("Buffer.readUInt16LE ", () => buf.readUInt16LE(0)); -// time("DataView.readUInt16 (LE)", () => view.getUint16(0, true)); -// console.log(""); -time("Buffer.readUInt32BE ", () => buf.readUInt32BE(0)); -// time("DataView.getUInt32 (BE)", () => view.getUint32(0, false)); -// console.log(""); -time("Buffer.readUInt32LE ", () => buf.readUInt32LE(0)); -// time("DataView.getUInt32 (LE)", () => view.getUint32(0, true)); -// console.log(""); -time("Buffer.readUInt8 ", () => buf.readUInt8(0)); -// time("DataView.getUInt (t8)", () => view.getUint8(0)); -// console.log(""); - -time("Buffer.writeBigInt64BE", () => buf.writeBigInt64BE(BigInt(0), 0)); -// time("DataView.getBigInt64 (BE)", () => view.getBigInt64(0, false)); -// console.log(""); -time("Buffer.writeBigInt64LE", () => buf.writeBigInt64LE(BigInt(0), 0)); -// time("DataView.readBigInt64 (LE)", () => view.getBigInt64(0, true)); -// console.log(""); -time("Buffer.writeBigUInt64BE", () => buf.writeBigUInt64BE(BigInt(0), 0)); -// time("DataView.getBigUInt64 (BE)", () => view.getBigUint64(0, false)); -// console.log(""); -time("Buffer.writeBigUInt64LE", () => buf.writeBigUInt64LE(BigInt(0), 0)); -// time("DataView.readBigUInt64 (LE)", () => view.getBigUint64(0, true)); -// console.log(""); -time("Buffer.writeDoubleBE ", () => buf.writeDoubleBE(0, 0)); -// time("DataView.getDouble (BE)", () => view.getFloat64(0, false)); -// console.log(""); -time("Buffer.writeDoubleLE ", () => buf.writeDoubleLE(0, 0)); -// time("DataView.readDouble (LE)", () => view.getFloat64(0, true)); -// console.log(""); -time("Buffer.writeFloatBE ", () => buf.writeFloatBE(0, 0)); -// time("DataView.getFloat (BE)", () => view.getFloat32(0, false)); -// console.log(""); -time("Buffer.writeFloatLE ", () => buf.writeFloatLE(0, 0)); -// time("DataView.readFloat (LE)", () => view.getFloat32(0, true)); -// console.log(""); -time("Buffer.writeInt16BE ", () => buf.writeInt16BE(0, 0)); -// time("DataView.getInt16 (BE)", () => view.getInt16(0, false)); -// console.log(""); -time("Buffer.writeInt16LE ", () => buf.writeInt16LE(0, 0)); -// time("DataView.readInt16 (LE)", () => view.getInt16(0, true)); -// console.log(""); -time("Buffer.writeInt32BE ", () => buf.writeInt32BE(0, 0)); -// time("DataView.getInt32 (BE)", () => view.getInt32(0, false)); -// console.log(""); -time("Buffer.writeInt32LE ", () => buf.writeInt32LE(0, 0)); -// time("DataView.readInt32 (LE)", () => view.getInt32(0, true)); -// console.log(""); -time("Buffer.writeInt8 ", () => buf.writeInt8(0, 0)); -// time("DataView.readInt (t8)", () => view.getInt8(0)); -// console.log(""); -time("Buffer.writeUInt16BE ", () => buf.writeUInt16BE(0, 0)); -// time("DataView.getUInt16 (BE)", () => view.getUint16(0, false)); -// console.log(""); -time("Buffer.writeUInt16LE ", () => buf.writeUInt16LE(0, 0)); -// time("DataView.readUInt16 (LE)", () => view.getUint16(0, true)); -// console.log(""); -time("Buffer.writeUInt32BE ", () => buf.writeUInt32BE(0, 0)); -// time("DataView.getUInt32 (BE)", () => view.getUint32(0, false)); -// console.log(""); -time("Buffer.writeUInt32LE ", () => buf.writeUInt32LE(0, 0)); -// time("DataView.getUInt32 (LE)", () => view.getUint32(0, true)); -// console.log(""); -time("Buffer.writeUInt8 ", () => buf.writeUInt8(0, 0)); -// time("DataView.getUInt (t8)", () => view.getUint8(0)); -// console.log(""); - -buf.writeUInt8(10, 10); -console.assert(buf.readUInt8(10, 10) === 10); diff --git a/bench/snippets/callbacks-overhead.mjs b/bench/snippets/callbacks-overhead.mjs deleted file mode 100644 index 65171145c..000000000 --- a/bench/snippets/callbacks-overhead.mjs +++ /dev/null @@ -1,78 +0,0 @@ -const iterations = 1_000; - -export var report = { - async: 0, - callback: 0, - sync: 0, - then: 0, -}; - -const tests = { - callback(n, cb) { - if (n === iterations) return cb(); - tests.callback(1 + n, () => cb()); - }, - - sync(n) { - if (n === iterations) return; - - tests.sync(1 + n); - }, - - async async(n) { - if (n === iterations) return; - - await tests.async(1 + n); - }, - - then(n) { - if (n === iterations) return; - return Promise.resolve(1 + n).then(tests.then); - }, -}; - -async function test(log) { - { - const a = performance.now(); - await tests.async(0); - if (log) - console.log( - `async/await: ${(report.async = (performance.now() - a).toFixed(4))}ms` - ); - } - - { - const a = performance.now(); - tests.callback(0, function () { - if (log) - console.log( - `callback: ${(report.callback = (performance.now() - a).toFixed( - 4 - ))}ms` - ); - }); - } - - { - const a = performance.now(); - await tests.then(0); - if (log) - console.log( - `then: ${(report.then = (performance.now() - a).toFixed(4))}ms` - ); - } - - { - const a = performance.now(); - tests.sync(0); - if (log) - console.log( - `sync: ${(report.sync = (performance.now() - a).toFixed(4))}ms` - ); - } -} - -let warmup = 10; -while (warmup--) await test(); - -await test(true); diff --git a/bench/snippets/cat.bun.js b/bench/snippets/cat.bun.js deleted file mode 100644 index 1bb1c809a..000000000 --- a/bench/snippets/cat.bun.js +++ /dev/null @@ -1,5 +0,0 @@ -import { resolve } from "path"; -const { write, stdout, file } = Bun; -const input = resolve(process.argv[process.argv.length - 1]); - -await write(stdout, file(input)); diff --git a/bench/snippets/cat.mjs b/bench/snippets/cat.mjs deleted file mode 100644 index ca6dfe838..000000000 --- a/bench/snippets/cat.mjs +++ /dev/null @@ -1,6 +0,0 @@ -// works in both bun & node -import { readFileSync } from "node:fs"; -const count = parseInt(process.env.ITERATIONS || "1", 10) || 1; -const arg = process.argv.slice(1); -for (let i = 0; i < count; i++) - console.log(arg.map((file) => readFileSync(file, "utf8")).join("")); diff --git a/bench/snippets/cat.node.js b/bench/snippets/cat.node.js deleted file mode 100644 index d38d7c537..000000000 --- a/bench/snippets/cat.node.js +++ /dev/null @@ -1,4 +0,0 @@ -const path = require("path"); -const fs = require("fs"); -const input = path.resolve(process.argv[process.argv.length - 1]); -fs.createReadStream(input).pipe(process.stdout); diff --git a/bench/snippets/concat.js b/bench/snippets/concat.js deleted file mode 100644 index 46c6e0f7d..000000000 --- a/bench/snippets/concat.js +++ /dev/null @@ -1,66 +0,0 @@ -import { bench, group, run } from "mitata"; -import { readFileSync } from "fs"; -import { allocUnsafe } from "bun"; - -function polyfill(chunks) { - var size = 0; - for (const chunk of chunks) { - size += chunk.byteLength; - } - var buffer = new ArrayBuffer(size); - var view = new Uint8Array(buffer); - var offset = 0; - for (const chunk of chunks) { - view.set(chunk, offset); - offset += chunk.byteLength; - } - return buffer; -} - -function polyfillUninitialized(chunks) { - var size = 0; - for (const chunk of chunks) { - size += chunk.byteLength; - } - var view = allocUnsafe(size); - - var offset = 0; - for (const chunk of chunks) { - view.set(chunk, offset); - offset += chunk.byteLength; - } - return view.buffer; -} - -const chunkGroups = [ - [Uint8Array.from([123]), Uint8Array.from([456]), Uint8Array.from([789])], - Array.from(readFileSync(import.meta.path)).map((a) => Uint8Array.from([a])), - [readFileSync(import.meta.path)], - Array.from({ length: 42 }, () => readFileSync(import.meta.path)), - Array.from({ length: 2 }, () => - new TextEncoder().encode(readFileSync(import.meta.path, "utf8").repeat(100)) - ), -]; - -for (const chunks of chunkGroups) { - group( - `${chunks.reduce( - (prev, curr, i, a) => prev + curr.byteLength, - 0 - )} bytes for ${chunks.length} chunks`, - () => { - bench("Bun.concatArrayBuffers", () => { - Bun.concatArrayBuffers(chunks); - }); - bench("Uint8Array.set", () => { - polyfill(chunks); - }); - - bench("Uint8Array.set (uninitialized memory)", () => { - polyfillUninitialized(chunks); - }); - } - ); -} - -await run(); diff --git a/bench/snippets/copy.bun.js b/bench/snippets/copy.bun.js deleted file mode 100644 index 20269212a..000000000 --- a/bench/snippets/copy.bun.js +++ /dev/null @@ -1,4 +0,0 @@ -import path from "path"; -const input = path.resolve(process.argv[process.argv.length - 2]); -const output = path.resolve(process.argv[process.argv.length - 1]); -await Bun.write(Bun.file(output), Bun.file(input)); diff --git a/bench/snippets/copyfile.mjs b/bench/snippets/copyfile.mjs deleted file mode 100644 index 9db9faefe..000000000 --- a/bench/snippets/copyfile.mjs +++ /dev/null @@ -1,3 +0,0 @@ -import { copyFileSync } from "node:fs"; -const arg = process.argv.slice(2); -copyFileSync(arg[0], arg[1]); diff --git a/bench/snippets/escapeHTML.js b/bench/snippets/escapeHTML.js deleted file mode 100644 index f186b1d2f..000000000 --- a/bench/snippets/escapeHTML.js +++ /dev/null @@ -1,122 +0,0 @@ -import { group } from "mitata"; -import { bench, run } from "mitata"; -import { encode as htmlEntityEncode } from "html-entities"; -import { escape as heEscape } from "he"; - -var bunEscapeHTML = globalThis.escapeHTML || Bun.escapeHTML; - -const FIXTURE = require("fs") - .readFileSync(import.meta.dir + "/_fixture.txt", "utf8") - .split("") - .map((a) => { - if (a.charCodeAt(0) > 127) { - return "a"; - } - return a; - }) - .join(""); - -const FIXTURE_WITH_UNICODE = require("fs").readFileSync( - import.meta.dir + "/_fixture.txt", - "utf8" -); - -// from react-dom: -const matchHtmlRegExp = /["'&<>]/; - -function reactEscapeHtml(string) { - const str = "" + string; - const match = matchHtmlRegExp.exec(str); - - if (!match) { - return str; - } - - let escape; - let html = ""; - let index; - let lastIndex = 0; - - for (index = match.index; index < str.length; index++) { - switch (str.charCodeAt(index)) { - case 34: // " - escape = """; - break; - case 38: // & - escape = "&"; - break; - case 39: // ' - escape = "'"; // modified from escape-html; used to be ''' - break; - case 60: // < - escape = "<"; - break; - case 62: // > - escape = ">"; - break; - default: - continue; - } - - if (lastIndex !== index) { - html += str.substring(lastIndex, index); - } - - lastIndex = index + 1; - html += escape; - } - - return lastIndex !== index ? html + str.substring(lastIndex, index) : html; -} - -// for (let input of [ -// "", -// `long string, nothing to escape... `.repeat(9999), -// `long utf16 string, no esc 🤔🤔🤔🤔🤔` + "tex".repeat(4000), -// `smol`, -// // `medium string with `, - -// FIXTURE, -// // "[unicode]" + FIXTURE_WITH_UNICODE, -// ]) { -// group( -// { -// summary: true, -// name: -// `"` + -// input.substring(0, Math.min(input.length, 32)) + -// `"` + -// ` (${input.length} chars)`, -// }, -// () => { -// bench(`ReactDOM.escapeHTML`, () => reactEscapeHtml(input)); -// bench(`html-entities.encode`, () => htmlEntityEncode(input)); -// bench(`he.escape`, () => heEscape(input)); -// bench(`Bun.escapeHTML`, () => bunEscapeHTML(input)); -// } -// ); -// } - -for (let input of [ - `long string, nothing to escape... `.repeat(9999999 * 3), - FIXTURE.repeat(8000), - // "[unicode]" + FIXTURE_WITH_UNICODE, -]) { - group( - { - summary: true, - name: - `"` + - input.substring(0, Math.min(input.length, 32)) + - `"` + - ` (${new Intl.NumberFormat().format(input.length / 100_000_000_0)} GB)`, - }, - () => { - // bench(`ReactDOM.escapeHTML`, () => reactEscapeHtml(input)); - // bench(`html-entities.encode`, () => htmlEntityEncode(input)); - // bench(`he.escape`, () => heEscape(input)); - bench(`Bun.escapeHTML`, () => bunEscapeHTML(input)); - } - ); -} -await run(); diff --git a/bench/snippets/exists.js b/bench/snippets/exists.js deleted file mode 100644 index 1d1d6cfe0..000000000 --- a/bench/snippets/exists.js +++ /dev/null @@ -1,6 +0,0 @@ -const { existsSync } = require("fs"); -const cwd = process.cwd(); - -const count = parseInt(process.env.ITERATIONS || "1", 10) || 1; - -for (let i = 0; i < count; i++) existsSync(cwd); diff --git a/bench/snippets/gzip.js b/bench/snippets/gzip.js deleted file mode 100644 index 6d9971b39..000000000 --- a/bench/snippets/gzip.js +++ /dev/null @@ -1,20 +0,0 @@ -import { bench, group, run } from "mitata"; -import { gzipSync, gunzipSync } from "bun"; - -const data = new TextEncoder().encode("Hello World!".repeat(9999)); - -const compressed = gzipSync(data); - -bench(`roundtrip - "Hello World!".repeat(9999))`, () => { - gunzipSync(gzipSync(data)); -}); - -bench(`gzipSync("Hello World!".repeat(9999)))`, () => { - gzipSync(data); -}); - -bench(`gunzipSync("Hello World!".repeat(9999)))`, () => { - gunzipSync(compressed); -}); - -run({ collect: false, percentiles: true }); diff --git a/bench/snippets/gzip.node.mjs b/bench/snippets/gzip.node.mjs deleted file mode 100644 index d93104850..000000000 --- a/bench/snippets/gzip.node.mjs +++ /dev/null @@ -1,20 +0,0 @@ -import { bench, group, run } from "mitata"; -import { gzipSync, gunzipSync } from "zlib"; - -const data = new TextEncoder().encode("Hello World!".repeat(9999)); - -const compressed = gzipSync(data); - -bench(`roundtrip - "Hello World!".repeat(9999))`, () => { - gunzipSync(gzipSync(data)); -}); - -bench(`gzipSync("Hello World!".repeat(9999)))`, () => { - gzipSync(data); -}); - -bench(`gunzipSync("Hello World!".repeat(9999)))`, () => { - gunzipSync(compressed); -}); - -run({ collect: false, percentiles: true }); diff --git a/bench/snippets/jsx-entity-decoding.jsx b/bench/snippets/jsx-entity-decoding.jsx deleted file mode 100644 index 29834d781..000000000 --- a/bench/snippets/jsx-entity-decoding.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import React from "react"; - -export default ( - <> - ‍‍‍‍‍‍&zwjϑ≅≅≅≅≅≅≅≅ - üüüüüüü£åååååååå - óóóóóóóΠμμμμμμμμ - ♣♣♣♣♣♣&clubs⊕¢¢¢¢¢¢¢¢ - ÏÏÏÏÏÏÏ‌þþþþþþþþ - ………………&hellip°<<<<<<<< - λλλλλλ&lambdaρ⇓⇓⇓⇓⇓⇓⇓⇓ - ⇔⇔⇔⇔⇔⇔&hArrΤ≠≠≠≠≠≠≠≠ - ûûûûûûû•⊥⊥⊥⊥⊥⊥⊥⊥ - ôôôôôôô¶óóóóóóóó - ⊂⊂⊂⊂⊂⊂&subáíííííííí - ¸¸¸¸¸¸¸«§§§§§§§§ - ¨¨¨¨¨¨¨ς"""""""" - ÔÔÔÔÔÔÔ∫¥¥¥¥¥¥¥¥ - ςςςςςς&sigmafΕ«««««««« - ♦♦♦♦♦♦&diamsÓªªªªªªªª - ∞∞∞∞∞∞&infin⇔⋅⋅⋅⋅⋅⋅⋅⋅ - òòòòòòòý×××××××× - ⌈⌈⌈⌈⌈⌈&lceilωßßßßßßßß - ≥≥≥≥≥≥&geßüüüüüüüü - ρρρρρρ&rhoš∝∝∝∝∝∝∝∝ - ◊◊◊◊◊◊&lozχ↵↵↵↵↵↵↵↵ - ÈÈÈÈÈÈÈ ÅÅÅÅÅÅÅÅ - -); diff --git a/bench/snippets/noop.js b/bench/snippets/noop.js deleted file mode 100644 index 789e6abbb..000000000 --- a/bench/snippets/noop.js +++ /dev/null @@ -1,17 +0,0 @@ -import { bench, run } from "mitata"; - -var noop = globalThis[Symbol.for("Bun.lazy")]("noop"); - -bench("function", function () { - noop.function(); -}); - -bench("setter", function () { - noop.getterSetter = 1; -}); - -bench("getter", function () { - noop.getterSetter; -}); - -run(); diff --git a/bench/snippets/package.json b/bench/snippets/package.json deleted file mode 100644 index 1025e4fd8..000000000 --- a/bench/snippets/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "snippets", - "version": "1.0.0", - "main": "index.js", - "license": "MIT", - "dependencies": { - "@babel/core": "^7.16.10", - "@babel/preset-react": "^7.16.7", - "@swc/core": "^1.2.133", - "esbuild": "^0.14.12" - } -} diff --git a/bench/snippets/realpath.mjs b/bench/snippets/realpath.mjs deleted file mode 100644 index 9c3793d80..000000000 --- a/bench/snippets/realpath.mjs +++ /dev/null @@ -1,4 +0,0 @@ -import { realpathSync } from "node:fs"; -const count = parseInt(process.env.ITERATIONS || "1", 10) || 1; -const arg = process.argv[process.argv.length - 1]; -for (let i = 0; i < count; i++) realpathSync(arg); diff --git a/bench/snippets/render.js b/bench/snippets/render.js deleted file mode 100644 index 9ef70bc27..000000000 --- a/bench/snippets/render.js +++ /dev/null @@ -1,4 +0,0 @@ -import decoding from "./jsx-entity-decoding"; -import ReactDOMServer from "react-dom/server.browser"; - -console.log(ReactDOMServer.renderToString(decoding)); diff --git a/bench/snippets/scanner/bun.lockb b/bench/snippets/scanner/bun.lockb deleted file mode 100755 index 90bb78996..000000000 Binary files a/bench/snippets/scanner/bun.lockb and /dev/null differ diff --git a/bench/snippets/scanner/package.json b/bench/snippets/scanner/package.json deleted file mode 100644 index 7bb4e8990..000000000 --- a/bench/snippets/scanner/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "scan", - "dependencies": { - "esbuild": "^0.14.11" - } -} \ No newline at end of file diff --git a/bench/snippets/scanner/remix-route.ts b/bench/snippets/scanner/remix-route.ts deleted file mode 100644 index dbacf3a4c..000000000 --- a/bench/snippets/scanner/remix-route.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { useParams } from "remix"; -import type { LoaderFunction, ActionFunction } from "remix"; - -export const loader: LoaderFunction = async ({ params }) => { - console.log(params.postId); -}; - -export const action: ActionFunction = async ({ params }) => { - console.log(params.postId); -}; - -export default function PostRoute() { - const params = useParams(); - console.log(params.postId); -} diff --git a/bench/snippets/scanner/scan-imports-only.js b/bench/snippets/scanner/scan-imports-only.js deleted file mode 100644 index 53222d57c..000000000 --- a/bench/snippets/scanner/scan-imports-only.js +++ /dev/null @@ -1,15 +0,0 @@ -import { readFileSync } from "fs"; -const fixture = ["action", "default", "loader"]; - -const transpiler = new Bun.Transpiler({ - loader: "ts", -}); - -console.time("Get exports"); -const ITERATIONS = parseInt(process.env.ITERATIONS || "1") || 1; -for (let i = 0; i < ITERATIONS; i++) { - const imports = transpiler.scanImports( - readFileSync("remix-route.ts", "utf8") - ); -} -console.timeEnd("Get exports"); diff --git a/bench/snippets/scanner/scan.bun.js b/bench/snippets/scanner/scan.bun.js deleted file mode 100644 index eb2b09452..000000000 --- a/bench/snippets/scanner/scan.bun.js +++ /dev/null @@ -1,21 +0,0 @@ -import { readFileSync } from "fs"; -const fixture = ["action", "default", "loader"]; -const ITERATIONS = parseInt(process.env.ITERATIONS || "1") || 1; - -const transpiler = new Bun.Transpiler({ - loader: "ts", -}); - -console.time("Get exports"); -const file = readFileSync("remix-route.ts", "utf8"); -for (let i = 0; i < ITERATIONS; i++) { - const { imports, exports } = transpiler.scan(file); - - for (let j = 0; j < fixture.length; j++) { - if (fixture[j] !== exports[j]) { - throw new Error("Mismatch"); - } - } -} - -console.timeEnd("Get exports"); diff --git a/bench/snippets/scanner/scan.node-esbuild.mjs b/bench/snippets/scanner/scan.node-esbuild.mjs deleted file mode 100644 index 1a7fa79d8..000000000 --- a/bench/snippets/scanner/scan.node-esbuild.mjs +++ /dev/null @@ -1,42 +0,0 @@ -import { build, buildSync } from "esbuild"; -import { readFileSync } from "fs"; -const fixture = ["action", "default", "loader"]; -const ITERATIONS = parseInt(process.env.ITERATIONS || "1") || 1; - -const opts = { - metafile: true, - format: "esm", - platform: "neutral", - write: false, - logLevel: "silent", - stdin: { - contents: readFileSync("remix-route.ts", "utf8"), - loader: "ts", - sourcefile: "remix-route.js", - }, -}; - -const getExports = ({ metafile }) => { - for (let i = 0; i < fixture.length; i++) { - if (fixture[i] !== metafile.outputs["stdin.js"].exports[i]) { - throw new Error("Mismatch"); - } - } -}; - -console.time("Get exports"); - -if (!process.env.SYNC) { - var promises = new Array(ITERATIONS); - for (let i = 0; i < ITERATIONS; i++) { - promises[i] = build(opts).then(getExports); - } - - await Promise.all(promises); -} else { - for (let i = 0; i < ITERATIONS; i++) { - getExports(buildSync(opts)); - } -} - -console.timeEnd("Get exports"); diff --git a/bench/snippets/transpiler.mjs b/bench/snippets/transpiler.mjs deleted file mode 100644 index 6872d88b7..000000000 --- a/bench/snippets/transpiler.mjs +++ /dev/null @@ -1,58 +0,0 @@ -import { readFileSync } from "fs"; - -var transformSync; -var transform; -var opts; -if (process.isBun) { - const transpiler = new Bun.Transpiler({ loader: "jsx" }); - transformSync = transpiler.transformSync.bind(transpiler); - transform = transpiler.transform.bind(transpiler); - opts = "jsx"; -} else if (process.env["esbuild"]) { - try { - const esbuild = await import("esbuild"); - transformSync = esbuild.transformSync; - transform = esbuild.transform; - opts = { loader: "jsx" }; - } catch (exception) { - throw exception; - } -} else if (process.env["swc"]) { - try { - const swc = await import("@swc/core"); - transformSync = swc.transformSync; - transform = swc.transform; - opts = { - sourceMaps: false, - inlineSourcesContent: false, - jsc: { - target: "es2022", - parser: { - jsx: true, - }, - }, - }; - } catch (exception) { - throw exception; - } -} else if (process.env["babel"]) { - try { - const swc = await import("@babel/core"); - transformSync = swc.transformSync; - transform = swc.transform; - opts = { - sourceMaps: false, - presets: [(await import("@babel/preset-react")).default], - }; - } catch (exception) { - throw exception; - } -} - -const code = readFileSync("src/test/fixtures/simple.jsx", "utf8"); - -if (process.env.ASYNC) { - console.log(await transform(code, opts)); -} else { - console.log(transformSync(code, opts)); -} -- cgit v1.2.3