aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/headers.mjs
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-15 18:32:57 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-15 18:32:57 -0800
commit3b802c9a130683ff1f08858940892ed8f0a2f16c (patch)
tree1a7af976d32295d6a4864da4a374b3c96061d246 /bench/snippets/headers.mjs
parent996e5dd235172bb14d286add7313306a8a8b772c (diff)
downloadbun-3b802c9a130683ff1f08858940892ed8f0a2f16c.tar.gz
bun-3b802c9a130683ff1f08858940892ed8f0a2f16c.tar.zst
bun-3b802c9a130683ff1f08858940892ed8f0a2f16c.zip
Add non-standard headers API types
cc @colinhacks @Electroid
Diffstat (limited to 'bench/snippets/headers.mjs')
-rw-r--r--bench/snippets/headers.mjs40
1 files changed, 40 insertions, 0 deletions
diff --git a/bench/snippets/headers.mjs b/bench/snippets/headers.mjs
new file mode 100644
index 000000000..ace0d9f00
--- /dev/null
+++ b/bench/snippets/headers.mjs
@@ -0,0 +1,40 @@
+import { bench, run } from "../node_modules/mitata/src/cli.mjs";
+
+// pure JS implementation will optimze this out
+bench("new Headers", function () {
+ return new Headers();
+});
+
+var big = new Headers({
+ "Content-Type": "text/plain",
+ "Content-Length": "123",
+ "X-Custom-Header": "Hello World",
+ "X-Another-Custom-Header": "Hello World",
+ "X-Yet-Another-Custom-ader": "Hello World",
+ "X-Yet-Another-Custom-Heder": "Hello World",
+ "X-Yet-Another-Custom-Heade": "Hello World",
+ "X-Yet-Another-Custom-Headz": "Hello Worlda",
+});
+
+bench("Header.get", function () {
+ return big.get("Content-Type");
+});
+
+bench("Header.set (standard)", function () {
+ return big.set("Content-Type", "text/html");
+});
+
+bench("Header.set (non-standard)", function () {
+ return big.set("X-My-Custom", "text/html123");
+});
+
+if (big.toJSON)
+ bench("Header.toJSON", function () {
+ return big.toJSON();
+ });
+
+bench("Header fromEntries", function () {
+ return Object.fromEntries(big.entries());
+});
+
+run();