summaryrefslogtreecommitdiff
path: root/tests/specs/bench
diff options
context:
space:
mode:
Diffstat (limited to 'tests/specs/bench')
-rw-r--r--tests/specs/bench/allow_all/__test__.jsonc5
-rw-r--r--tests/specs/bench/allow_all/allow_all.out23
-rw-r--r--tests/specs/bench/allow_all/allow_all.ts43
-rw-r--r--tests/specs/bench/allow_none/__test__.jsonc5
-rw-r--r--tests/specs/bench/allow_none/allow_none.out22
-rw-r--r--tests/specs/bench/allow_none/allow_none.ts21
-rw-r--r--tests/specs/bench/before_unload_prevent_default/__test__.jsonc4
-rw-r--r--tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.out7
-rw-r--r--tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.ts6
-rw-r--r--tests/specs/bench/bench_explicit_start_end/__test__.jsonc5
-rw-r--r--tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.out25
-rw-r--r--tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.ts50
-rw-r--r--tests/specs/bench/bench_formatting/__test__.jsonc5
-rw-r--r--tests/specs/bench/bench_formatting/bench_formatting.out8
-rw-r--r--tests/specs/bench/bench_formatting/bench_formatting.ts3
-rw-r--r--tests/specs/bench/check_local_by_default/__test__.jsonc4
-rw-r--r--tests/specs/bench/check_local_by_default/check_local_by_default.out6
-rw-r--r--tests/specs/bench/check_local_by_default/check_local_by_default.ts3
-rw-r--r--tests/specs/bench/check_local_by_default2/__test__.jsonc5
-rw-r--r--tests/specs/bench/check_local_by_default2/check_local_by_default2.out4
-rw-r--r--tests/specs/bench/check_local_by_default2/check_local_by_default2.ts6
-rw-r--r--tests/specs/bench/clear_timeout/__test__.jsonc5
-rw-r--r--tests/specs/bench/clear_timeout/clear_timeout.out10
-rw-r--r--tests/specs/bench/clear_timeout/clear_timeout.ts5
-rw-r--r--tests/specs/bench/collect/__test__.jsonc19
-rw-r--r--tests/specs/bench/collect/collect.out18
-rw-r--r--tests/specs/bench/collect/collect/bench.ts0
-rw-r--r--tests/specs/bench/collect/collect/deno.jsonc5
-rw-r--r--tests/specs/bench/collect/collect/deno.malformed.jsonc5
-rw-r--r--tests/specs/bench/collect/collect/deno2.jsonc6
-rw-r--r--tests/specs/bench/collect/collect/ignore/bench.ts1
-rw-r--r--tests/specs/bench/collect/collect/include/2_bench.ts0
-rw-r--r--tests/specs/bench/collect/collect/include/bench.ts0
-rw-r--r--tests/specs/bench/collect/collect2.out13
-rw-r--r--tests/specs/bench/collect/collect_with_malformed_config.out4
-rw-r--r--tests/specs/bench/exit_sanitizer/__test__.jsonc5
-rw-r--r--tests/specs/bench/exit_sanitizer/exit_sanitizer.out14
-rw-r--r--tests/specs/bench/exit_sanitizer/exit_sanitizer.ts11
-rw-r--r--tests/specs/bench/explicit_start_and_end_low_precision/__test__.jsonc5
-rw-r--r--tests/specs/bench/explicit_start_and_end_low_precision/main.bench.out10
-rw-r--r--tests/specs/bench/explicit_start_and_end_low_precision/main.bench.ts4
-rw-r--r--tests/specs/bench/fail/__test__.jsonc5
-rw-r--r--tests/specs/bench/fail/fail.out28
-rw-r--r--tests/specs/bench/fail/fail.ts30
-rw-r--r--tests/specs/bench/filter/__test__.jsonc4
-rw-r--r--tests/specs/bench/filter/a_bench.ts3
-rw-r--r--tests/specs/bench/filter/b_bench.ts3
-rw-r--r--tests/specs/bench/filter/c_bench.ts3
-rw-r--r--tests/specs/bench/filter/filter.out20
-rw-r--r--tests/specs/bench/filter_group_header/main.out4
-rw-r--r--tests/specs/bench/finally_timeout/__test__.jsonc5
-rw-r--r--tests/specs/bench/finally_timeout/finally_timeout.out11
-rw-r--r--tests/specs/bench/finally_timeout/finally_timeout.ts11
-rw-r--r--tests/specs/bench/group_baseline/__test__.jsonc5
-rw-r--r--tests/specs/bench/group_baseline/group_baseline.out20
-rw-r--r--tests/specs/bench/group_baseline/group_baseline.ts15
-rw-r--r--tests/specs/bench/ignore/__test__.jsonc5
-rw-r--r--tests/specs/bench/ignore/ignore.out8
-rw-r--r--tests/specs/bench/ignore/ignore.ts9
-rw-r--r--tests/specs/bench/ignore_permissions/__test__.jsonc5
-rw-r--r--tests/specs/bench/ignore_permissions/ignore_permissions.out8
-rw-r--r--tests/specs/bench/ignore_permissions/ignore_permissions.ts16
-rw-r--r--tests/specs/bench/interval/__test__.jsonc5
-rw-r--r--tests/specs/bench/interval/interval.out8
-rw-r--r--tests/specs/bench/interval/interval.ts1
-rw-r--r--tests/specs/bench/json_output/__test__.jsonc5
-rw-r--r--tests/specs/bench/json_output/pass.json.out28
-rw-r--r--tests/specs/bench/json_output/pass.ts10
-rw-r--r--tests/specs/bench/load_unload/__test__.jsonc5
-rw-r--r--tests/specs/bench/load_unload/load_unload.out8
-rw-r--r--tests/specs/bench/load_unload/load_unload.ts22
-rw-r--r--tests/specs/bench/meta/__test__.jsonc5
-rw-r--r--tests/specs/bench/meta/meta.out10
-rw-r--r--tests/specs/bench/meta/meta.ts2
-rw-r--r--tests/specs/bench/multifile_summary/__test__.jsonc5
-rw-r--r--tests/specs/bench/multifile_summary/group_baseline.ts15
-rw-r--r--tests/specs/bench/multifile_summary/multifile_summary.out64
-rw-r--r--tests/specs/bench/multifile_summary/multiple_group.ts15
-rw-r--r--tests/specs/bench/multifile_summary/pass.ts10
-rw-r--r--tests/specs/bench/no_check/__test__.jsonc5
-rw-r--r--tests/specs/bench/no_check/no_check.out9
-rw-r--r--tests/specs/bench/no_check/no_check.ts1
-rw-r--r--tests/specs/bench/no_prompt_by_default/__test__.jsonc5
-rw-r--r--tests/specs/bench/no_prompt_by_default/no_prompt_by_default.out9
-rw-r--r--tests/specs/bench/no_prompt_by_default/no_prompt_by_default.ts3
-rw-r--r--tests/specs/bench/no_prompt_with_denied_perms/__test__.jsonc5
-rw-r--r--tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.out9
-rw-r--r--tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.ts3
-rw-r--r--tests/specs/bench/no_run/__test__.jsonc5
-rw-r--r--tests/specs/bench/no_run/no_run.out5
-rw-r--r--tests/specs/bench/no_run/no_run.ts2
-rw-r--r--tests/specs/bench/only/__test__.jsonc5
-rw-r--r--tests/specs/bench/only/only.out9
-rw-r--r--tests/specs/bench/only/only.ts15
-rw-r--r--tests/specs/bench/overloads/__test__.jsonc5
-rw-r--r--tests/specs/bench/overloads/overloads.out12
-rw-r--r--tests/specs/bench/overloads/overloads.ts6
-rw-r--r--tests/specs/bench/package_json/__test__.jsonc5
-rw-r--r--tests/specs/bench/package_json/lib.bench.out11
-rw-r--r--tests/specs/bench/package_json/lib.bench.ts7
-rw-r--r--tests/specs/bench/package_json/lib.ts9
-rw-r--r--tests/specs/bench/package_json/package.json5
-rw-r--r--tests/specs/bench/pass/__test__.jsonc5
-rw-r--r--tests/specs/bench/pass/pass.out17
-rw-r--r--tests/specs/bench/pass/pass.ts10
-rw-r--r--tests/specs/bench/quiet/__test__.jsonc5
-rw-r--r--tests/specs/bench/quiet/quiet.out10
-rw-r--r--tests/specs/bench/quiet/quiet.ts15
-rw-r--r--tests/specs/bench/unhandled_rejection/__test__.jsonc5
-rw-r--r--tests/specs/bench/unhandled_rejection/unhandled_rejection.out11
-rw-r--r--tests/specs/bench/unhandled_rejection/unhandled_rejection.ts3
-rw-r--r--tests/specs/bench/unresolved_promise/__test__.jsonc5
-rw-r--r--tests/specs/bench/unresolved_promise/unresolved_promise.out9
-rw-r--r--tests/specs/bench/unresolved_promise/unresolved_promise.ts1
114 files changed, 1080 insertions, 2 deletions
diff --git a/tests/specs/bench/allow_all/__test__.jsonc b/tests/specs/bench/allow_all/__test__.jsonc
new file mode 100644
index 000000000..dcc5cc421
--- /dev/null
+++ b/tests/specs/bench/allow_all/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench --allow-all allow_all.ts",
+ "output": "allow_all.out",
+ "exitCode": 0
+}
diff --git a/tests/specs/bench/allow_all/allow_all.out b/tests/specs/bench/allow_all/allow_all.out
new file mode 100644
index 000000000..0c6a8a034
--- /dev/null
+++ b/tests/specs/bench/allow_all/allow_all.out
@@ -0,0 +1,23 @@
+[WILDCARD]
+Check [WILDLINE]/allow_all.ts
+cpu: [WILDLINE]
+runtime: deno [WILDLINE] ([WILDLINE])
+
+[WILDLINE]/allow_all.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+------------------------------------------------------------------ -----------------------------
+read false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE]
+read true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE]
+write false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE]
+write true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE]
+net false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE]
+net true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE]
+env false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE]
+env true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE]
+run false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE]
+run true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE]
+ffi false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE]
+ffi true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE]
+hrtime false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE]
+hrtime true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE]
+
diff --git a/tests/specs/bench/allow_all/allow_all.ts b/tests/specs/bench/allow_all/allow_all.ts
new file mode 100644
index 000000000..9747fb414
--- /dev/null
+++ b/tests/specs/bench/allow_all/allow_all.ts
@@ -0,0 +1,43 @@
+import { assertEquals } from "jsr:@std/assert";
+
+const permissions: Deno.PermissionName[] = [
+ "read",
+ "write",
+ "net",
+ "env",
+ "run",
+ "ffi",
+ "hrtime",
+];
+
+for (const name of permissions) {
+ Deno.bench({
+ name: `${name} false`,
+ permissions: {
+ [name]: false,
+ },
+ async fn() {
+ for await (const n of permissions) {
+ const status = await Deno.permissions.query({ name: n });
+ assertEquals(status.state, "prompt");
+ }
+ },
+ });
+
+ Deno.bench({
+ name: `${name} true`,
+ permissions: {
+ [name]: true,
+ },
+ async fn() {
+ for await (const n of permissions) {
+ const status = await Deno.permissions.query({ name: n });
+ if (n === name) {
+ assertEquals(status.state, "granted");
+ } else {
+ assertEquals(status.state, "prompt");
+ }
+ }
+ },
+ });
+}
diff --git a/tests/specs/bench/allow_none/__test__.jsonc b/tests/specs/bench/allow_none/__test__.jsonc
new file mode 100644
index 000000000..9ae51f75b
--- /dev/null
+++ b/tests/specs/bench/allow_none/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench allow_none.ts",
+ "output": "allow_none.out",
+ "exitCode": 1
+}
diff --git a/tests/specs/bench/allow_none/allow_none.out b/tests/specs/bench/allow_none/allow_none.out
new file mode 100644
index 000000000..cfe86adcb
--- /dev/null
+++ b/tests/specs/bench/allow_none/allow_none.out
@@ -0,0 +1,22 @@
+Check [WILDLINE]/allow_none.ts
+cpu: [WILDLINE]
+runtime: deno [WILDLINE] ([WILDLINE])
+
+[WILDLINE]/allow_none.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+read error: PermissionDenied: Can't escalate parent thread permissions
+[WILDCARD]
+write error: PermissionDenied: Can't escalate parent thread permissions
+[WILDCARD]
+net error: PermissionDenied: Can't escalate parent thread permissions
+[WILDCARD]
+env error: PermissionDenied: Can't escalate parent thread permissions
+[WILDCARD]
+run error: PermissionDenied: Can't escalate parent thread permissions
+[WILDCARD]
+ffi error: PermissionDenied: Can't escalate parent thread permissions
+[WILDCARD]
+hrtime error: PermissionDenied: Can't escalate parent thread permissions
+[WILDCARD]
+error: Bench failed
diff --git a/tests/specs/bench/allow_none/allow_none.ts b/tests/specs/bench/allow_none/allow_none.ts
new file mode 100644
index 000000000..77f86f256
--- /dev/null
+++ b/tests/specs/bench/allow_none/allow_none.ts
@@ -0,0 +1,21 @@
+const permissions: Deno.PermissionName[] = [
+ "read",
+ "write",
+ "net",
+ "env",
+ "run",
+ "ffi",
+ "hrtime",
+];
+
+for (const name of permissions) {
+ Deno.bench({
+ name,
+ permissions: {
+ [name]: true,
+ },
+ fn() {
+ throw new Error("unreachable");
+ },
+ });
+}
diff --git a/tests/specs/bench/before_unload_prevent_default/__test__.jsonc b/tests/specs/bench/before_unload_prevent_default/__test__.jsonc
new file mode 100644
index 000000000..5253af5df
--- /dev/null
+++ b/tests/specs/bench/before_unload_prevent_default/__test__.jsonc
@@ -0,0 +1,4 @@
+{
+ "args": "bench --quiet before_unload_prevent_default.ts",
+ "output": "before_unload_prevent_default.out"
+}
diff --git a/tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.out b/tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.out
new file mode 100644
index 000000000..dcb6d8194
--- /dev/null
+++ b/tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.out
@@ -0,0 +1,7 @@
+cpu: [WILDCARD]
+runtime: deno [WILDCARD]
+
+[WILDCARD]/before_unload_prevent_default.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+foo [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
diff --git a/tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.ts b/tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.ts
new file mode 100644
index 000000000..2759d4659
--- /dev/null
+++ b/tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.ts
@@ -0,0 +1,6 @@
+addEventListener("beforeunload", (e) => {
+ // The worker should be killed once benchmarks are done regardless of this.
+ e.preventDefault();
+});
+
+Deno.bench("foo", () => {});
diff --git a/tests/specs/bench/bench_explicit_start_end/__test__.jsonc b/tests/specs/bench/bench_explicit_start_end/__test__.jsonc
new file mode 100644
index 000000000..e8e5bf8c2
--- /dev/null
+++ b/tests/specs/bench/bench_explicit_start_end/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench --quiet -A explicit_start_and_end.ts",
+ "output": "explicit_start_and_end.out",
+ "exitCode": 1
+}
diff --git a/tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.out b/tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.out
new file mode 100644
index 000000000..fa118540c
--- /dev/null
+++ b/tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.out
@@ -0,0 +1,25 @@
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/explicit_start_and_end.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+------------------------------------------------------------------- -----------------------------
+start and end [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+start only [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+end only [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+double start error: TypeError: BenchContext::start() has already been invoked.
+ t.start();
+ ^
+ at BenchContext.start ([WILDCARD])
+ at [WILDCARD]/explicit_start_and_end.ts:[WILDCARD]
+double end error: TypeError: BenchContext::end() has already been invoked.
+ t.end();
+ ^
+ at BenchContext.end ([WILDCARD])
+ at [WILDCARD]/explicit_start_and_end.ts:[WILDCARD]
+captured error: TypeError: The benchmark which this context belongs to is not being executed.
+ captured!.start();
+ ^
+ at BenchContext.start ([WILDCARD])
+ at [WILDCARD]/explicit_start_and_end.ts:[WILDCARD]
+error: Bench failed
diff --git a/tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.ts b/tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.ts
new file mode 100644
index 000000000..60a3d10d7
--- /dev/null
+++ b/tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.ts
@@ -0,0 +1,50 @@
+Deno.bench("start and end", (t) => {
+ const id = setInterval(() => {}, 1000);
+ t.start();
+ Deno.inspect(id);
+ t.end();
+ clearInterval(id);
+});
+
+Deno.bench("start only", (t) => {
+ const id = setInterval(() => {}, 1000);
+ t.start();
+ Deno.inspect(id);
+ clearInterval(id);
+});
+
+Deno.bench("end only", (t) => {
+ const id = setInterval(() => {}, 1000);
+ Deno.inspect(id);
+ t.end();
+ clearInterval(id);
+});
+
+Deno.bench("double start", (t) => {
+ const id = setInterval(() => {}, 1000);
+ t.start();
+ t.start();
+ Deno.inspect(id);
+ t.end();
+ clearInterval(id);
+});
+
+let captured: Deno.BenchContext;
+
+Deno.bench("double end", (t) => {
+ captured = t;
+ const id = setInterval(() => {}, 1000);
+ t.start();
+ Deno.inspect(id);
+ t.end();
+ t.end();
+ clearInterval(id);
+});
+
+Deno.bench("captured", () => {
+ const id = setInterval(() => {}, 1000);
+ captured!.start();
+ Deno.inspect(id);
+ captured!.end();
+ clearInterval(id);
+});
diff --git a/tests/specs/bench/bench_formatting/__test__.jsonc b/tests/specs/bench/bench_formatting/__test__.jsonc
new file mode 100644
index 000000000..1f1d89394
--- /dev/null
+++ b/tests/specs/bench/bench_formatting/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench bench_formatting.ts",
+ "output": "bench_formatting.out",
+ "exitCode": 0
+}
diff --git a/tests/specs/bench/bench_formatting/bench_formatting.out b/tests/specs/bench/bench_formatting/bench_formatting.out
new file mode 100644
index 000000000..79617a32d
--- /dev/null
+++ b/tests/specs/bench/bench_formatting/bench_formatting.out
@@ -0,0 +1,8 @@
+Check [WILDCARD]/bench_formatting.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/bench_formatting.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+[WILDCARD] [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] \ No newline at end of file
diff --git a/tests/specs/bench/bench_formatting/bench_formatting.ts b/tests/specs/bench/bench_formatting/bench_formatting.ts
new file mode 100644
index 000000000..fdee15abb
--- /dev/null
+++ b/tests/specs/bench/bench_formatting/bench_formatting.ts
@@ -0,0 +1,3 @@
+Deno.bench("Date.now", () => {
+ Date.now();
+});
diff --git a/tests/specs/bench/check_local_by_default/__test__.jsonc b/tests/specs/bench/check_local_by_default/__test__.jsonc
new file mode 100644
index 000000000..76dd80b7b
--- /dev/null
+++ b/tests/specs/bench/check_local_by_default/__test__.jsonc
@@ -0,0 +1,4 @@
+{
+ "args": "bench --quiet check_local_by_default.ts",
+ "output": "check_local_by_default.out"
+}
diff --git a/tests/specs/bench/check_local_by_default/check_local_by_default.out b/tests/specs/bench/check_local_by_default/check_local_by_default.out
new file mode 100644
index 000000000..63a6b5fa5
--- /dev/null
+++ b/tests/specs/bench/check_local_by_default/check_local_by_default.out
@@ -0,0 +1,6 @@
+[WILDCARD]
+
+[WILDCARD]/check_local_by_default.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+
diff --git a/tests/specs/bench/check_local_by_default/check_local_by_default.ts b/tests/specs/bench/check_local_by_default/check_local_by_default.ts
new file mode 100644
index 000000000..2ae8c2692
--- /dev/null
+++ b/tests/specs/bench/check_local_by_default/check_local_by_default.ts
@@ -0,0 +1,3 @@
+import * as a from "http://localhost:4545/subdir/type_error.ts";
+
+console.log(a.a);
diff --git a/tests/specs/bench/check_local_by_default2/__test__.jsonc b/tests/specs/bench/check_local_by_default2/__test__.jsonc
new file mode 100644
index 000000000..5f2366d1e
--- /dev/null
+++ b/tests/specs/bench/check_local_by_default2/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench --quiet check_local_by_default2.ts",
+ "output": "check_local_by_default2.out",
+ "exitCode": 1
+}
diff --git a/tests/specs/bench/check_local_by_default2/check_local_by_default2.out b/tests/specs/bench/check_local_by_default2/check_local_by_default2.out
new file mode 100644
index 000000000..089b17f4b
--- /dev/null
+++ b/tests/specs/bench/check_local_by_default2/check_local_by_default2.out
@@ -0,0 +1,4 @@
+error: TS2322 [ERROR]: Type '12' is not assignable to type '"b"'.
+const b: "b" = 12;
+ ^
+ at [WILDCARD]/check_local_by_default2.ts:3:7
diff --git a/tests/specs/bench/check_local_by_default2/check_local_by_default2.ts b/tests/specs/bench/check_local_by_default2/check_local_by_default2.ts
new file mode 100644
index 000000000..5177ff944
--- /dev/null
+++ b/tests/specs/bench/check_local_by_default2/check_local_by_default2.ts
@@ -0,0 +1,6 @@
+import * as a from "http://localhost:4545/subdir/type_error.ts";
+
+const b: "b" = 12;
+
+console.log(a.a);
+console.log(b);
diff --git a/tests/specs/bench/clear_timeout/__test__.jsonc b/tests/specs/bench/clear_timeout/__test__.jsonc
new file mode 100644
index 000000000..4535c931d
--- /dev/null
+++ b/tests/specs/bench/clear_timeout/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench clear_timeout.ts",
+ "output": "clear_timeout.out",
+ "exitCode": 0
+}
diff --git a/tests/specs/bench/clear_timeout/clear_timeout.out b/tests/specs/bench/clear_timeout/clear_timeout.out
new file mode 100644
index 000000000..48a31378b
--- /dev/null
+++ b/tests/specs/bench/clear_timeout/clear_timeout.out
@@ -0,0 +1,10 @@
+Check [WILDCARD]/clear_timeout.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/clear_timeout.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+bench1 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
diff --git a/tests/specs/bench/clear_timeout/clear_timeout.ts b/tests/specs/bench/clear_timeout/clear_timeout.ts
new file mode 100644
index 000000000..4148263ac
--- /dev/null
+++ b/tests/specs/bench/clear_timeout/clear_timeout.ts
@@ -0,0 +1,5 @@
+clearTimeout(setTimeout(() => {}, 1000));
+
+Deno.bench("bench1", () => {});
+Deno.bench("bench2", () => {});
+Deno.bench("bench3", () => {});
diff --git a/tests/specs/bench/collect/__test__.jsonc b/tests/specs/bench/collect/__test__.jsonc
new file mode 100644
index 000000000..e5aabd82d
--- /dev/null
+++ b/tests/specs/bench/collect/__test__.jsonc
@@ -0,0 +1,19 @@
+{
+ "steps": [{
+ "args": "bench --ignore=collect/ignore collect",
+ "output": "collect.out"
+ }, {
+ "cleanDenoDir": true,
+ "args": "bench --config collect/deno.jsonc collect",
+ "output": "collect.out"
+ }, {
+ "cleanDenoDir": true,
+ "args": "bench --config collect/deno2.jsonc collect",
+ "output": "collect2.out"
+ }, {
+ "cleanDenoDir": true,
+ "args": "bench --config collect/deno.malformed.jsonc",
+ "exitCode": 1,
+ "output": "collect_with_malformed_config.out"
+ }]
+}
diff --git a/tests/specs/bench/collect/collect.out b/tests/specs/bench/collect/collect.out
new file mode 100644
index 000000000..0d3f7a8ff
--- /dev/null
+++ b/tests/specs/bench/collect/collect.out
@@ -0,0 +1,18 @@
+Check [WILDCARD]/collect/bench.ts
+Check [WILDCARD]/collect/include/2_bench.ts
+Check [WILDCARD]/collect/include/bench.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/collect/bench.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+
+[WILDCARD]/collect/include/2_bench.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+
+[WILDCARD]/collect/include/bench.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+
diff --git a/tests/specs/bench/collect/collect/bench.ts b/tests/specs/bench/collect/collect/bench.ts
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/specs/bench/collect/collect/bench.ts
diff --git a/tests/specs/bench/collect/collect/deno.jsonc b/tests/specs/bench/collect/collect/deno.jsonc
new file mode 100644
index 000000000..7f8f190d3
--- /dev/null
+++ b/tests/specs/bench/collect/collect/deno.jsonc
@@ -0,0 +1,5 @@
+{
+ "bench": {
+ "exclude": ["./ignore"]
+ }
+}
diff --git a/tests/specs/bench/collect/collect/deno.malformed.jsonc b/tests/specs/bench/collect/collect/deno.malformed.jsonc
new file mode 100644
index 000000000..8e558fbcf
--- /dev/null
+++ b/tests/specs/bench/collect/collect/deno.malformed.jsonc
@@ -0,0 +1,5 @@
+{
+ "bench": {
+ "dont_know_this_field": {}
+ }
+}
diff --git a/tests/specs/bench/collect/collect/deno2.jsonc b/tests/specs/bench/collect/collect/deno2.jsonc
new file mode 100644
index 000000000..653ab1e31
--- /dev/null
+++ b/tests/specs/bench/collect/collect/deno2.jsonc
@@ -0,0 +1,6 @@
+{
+ "bench": {
+ "include": ["./include/"],
+ "exclude": ["./ignore", "./include/2_bench.ts"]
+ }
+}
diff --git a/tests/specs/bench/collect/collect/ignore/bench.ts b/tests/specs/bench/collect/collect/ignore/bench.ts
new file mode 100644
index 000000000..16fb63ba7
--- /dev/null
+++ b/tests/specs/bench/collect/collect/ignore/bench.ts
@@ -0,0 +1 @@
+throw new Error("this module should be ignored");
diff --git a/tests/specs/bench/collect/collect/include/2_bench.ts b/tests/specs/bench/collect/collect/include/2_bench.ts
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/specs/bench/collect/collect/include/2_bench.ts
diff --git a/tests/specs/bench/collect/collect/include/bench.ts b/tests/specs/bench/collect/collect/include/bench.ts
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/specs/bench/collect/collect/include/bench.ts
diff --git a/tests/specs/bench/collect/collect2.out b/tests/specs/bench/collect/collect2.out
new file mode 100644
index 000000000..49ceee996
--- /dev/null
+++ b/tests/specs/bench/collect/collect2.out
@@ -0,0 +1,13 @@
+Check [WILDCARD]/collect/bench.ts
+Check [WILDCARD]/collect/include/bench.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/collect/bench.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+
+[WILDCARD]/collect/include/bench.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+
diff --git a/tests/specs/bench/collect/collect_with_malformed_config.out b/tests/specs/bench/collect/collect_with_malformed_config.out
new file mode 100644
index 000000000..92e5e29d2
--- /dev/null
+++ b/tests/specs/bench/collect/collect_with_malformed_config.out
@@ -0,0 +1,4 @@
+error: Failed to parse "bench" configuration
+
+Caused by:
+ unknown field `dont_know_this_field`, expected one of `include`, `exclude`, `files`
diff --git a/tests/specs/bench/exit_sanitizer/__test__.jsonc b/tests/specs/bench/exit_sanitizer/__test__.jsonc
new file mode 100644
index 000000000..a14531651
--- /dev/null
+++ b/tests/specs/bench/exit_sanitizer/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench exit_sanitizer.ts",
+ "output": "exit_sanitizer.out",
+ "exitCode": 1
+}
diff --git a/tests/specs/bench/exit_sanitizer/exit_sanitizer.out b/tests/specs/bench/exit_sanitizer/exit_sanitizer.out
new file mode 100644
index 000000000..eefc86e60
--- /dev/null
+++ b/tests/specs/bench/exit_sanitizer/exit_sanitizer.out
@@ -0,0 +1,14 @@
+Check [WILDCARD]/exit_sanitizer.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/exit_sanitizer.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+exit(0) error: Error: Bench attempted to exit with exit code: 0
+[WILDCARD]
+exit(1) error: Error: Bench attempted to exit with exit code: 1
+[WILDCARD]
+exit(2) error: Error: Bench attempted to exit with exit code: 2
+[WILDCARD]
+error: Bench failed
diff --git a/tests/specs/bench/exit_sanitizer/exit_sanitizer.ts b/tests/specs/bench/exit_sanitizer/exit_sanitizer.ts
new file mode 100644
index 000000000..8e596b310
--- /dev/null
+++ b/tests/specs/bench/exit_sanitizer/exit_sanitizer.ts
@@ -0,0 +1,11 @@
+Deno.bench("exit(0)", function () {
+ Deno.exit(0);
+});
+
+Deno.bench("exit(1)", function () {
+ Deno.exit(1);
+});
+
+Deno.bench("exit(2)", function () {
+ Deno.exit(2);
+});
diff --git a/tests/specs/bench/explicit_start_and_end_low_precision/__test__.jsonc b/tests/specs/bench/explicit_start_and_end_low_precision/__test__.jsonc
new file mode 100644
index 000000000..2cd093f3f
--- /dev/null
+++ b/tests/specs/bench/explicit_start_and_end_low_precision/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench --quiet -A main.bench.ts",
+ "output": "main.bench.out",
+ "flaky": true
+}
diff --git a/tests/specs/bench/explicit_start_and_end_low_precision/main.bench.out b/tests/specs/bench/explicit_start_and_end_low_precision/main.bench.out
new file mode 100644
index 000000000..516c001b1
--- /dev/null
+++ b/tests/specs/bench/explicit_start_and_end_low_precision/main.bench.out
@@ -0,0 +1,10 @@
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/main.bench.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+----------------------------------------------------------------------------- -----------------------------
+noop with start and end [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+Warning: start() and end() calls in "noop with start and end" are ignored because it averages less
+than 10µs per iteration. Remove them for better results.
+
diff --git a/tests/specs/bench/explicit_start_and_end_low_precision/main.bench.ts b/tests/specs/bench/explicit_start_and_end_low_precision/main.bench.ts
new file mode 100644
index 000000000..23bdf19fe
--- /dev/null
+++ b/tests/specs/bench/explicit_start_and_end_low_precision/main.bench.ts
@@ -0,0 +1,4 @@
+Deno.bench("noop with start and end", (b) => {
+ b.start();
+ b.end();
+});
diff --git a/tests/specs/bench/fail/__test__.jsonc b/tests/specs/bench/fail/__test__.jsonc
new file mode 100644
index 000000000..18748c31e
--- /dev/null
+++ b/tests/specs/bench/fail/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench fail.ts",
+ "output": "fail.out",
+ "exitCode": 1
+}
diff --git a/tests/specs/bench/fail/fail.out b/tests/specs/bench/fail/fail.out
new file mode 100644
index 000000000..03f04cf4f
--- /dev/null
+++ b/tests/specs/bench/fail/fail.out
@@ -0,0 +1,28 @@
+Check [WILDCARD]/fail.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/fail.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+bench0 error: Error
+[WILDCARD]
+bench1 error: Error
+[WILDCARD]
+bench2 error: Error
+[WILDCARD]
+bench3 error: Error
+[WILDCARD]
+bench4 error: Error
+[WILDCARD]
+bench5 error: Error
+[WILDCARD]
+bench6 error: Error
+[WILDCARD]
+bench7 error: Error
+[WILDCARD]
+bench8 error: Error
+[WILDCARD]
+bench9 error: Error
+[WILDCARD]
+error: Bench failed
diff --git a/tests/specs/bench/fail/fail.ts b/tests/specs/bench/fail/fail.ts
new file mode 100644
index 000000000..33d70ce55
--- /dev/null
+++ b/tests/specs/bench/fail/fail.ts
@@ -0,0 +1,30 @@
+Deno.bench("bench0", () => {
+ throw new Error();
+});
+Deno.bench("bench1", () => {
+ throw new Error();
+});
+Deno.bench("bench2", () => {
+ throw new Error();
+});
+Deno.bench("bench3", () => {
+ throw new Error();
+});
+Deno.bench("bench4", () => {
+ throw new Error();
+});
+Deno.bench("bench5", () => {
+ throw new Error();
+});
+Deno.bench("bench6", () => {
+ throw new Error();
+});
+Deno.bench("bench7", () => {
+ throw new Error();
+});
+Deno.bench("bench8", () => {
+ throw new Error();
+});
+Deno.bench("bench9", () => {
+ throw new Error();
+});
diff --git a/tests/specs/bench/filter/__test__.jsonc b/tests/specs/bench/filter/__test__.jsonc
new file mode 100644
index 000000000..685ee9571
--- /dev/null
+++ b/tests/specs/bench/filter/__test__.jsonc
@@ -0,0 +1,4 @@
+{
+ "args": "bench --filter=foo",
+ "output": "filter.out"
+}
diff --git a/tests/specs/bench/filter/a_bench.ts b/tests/specs/bench/filter/a_bench.ts
new file mode 100644
index 000000000..fc4ef859c
--- /dev/null
+++ b/tests/specs/bench/filter/a_bench.ts
@@ -0,0 +1,3 @@
+Deno.bench("foo", function () {});
+Deno.bench("bar", function () {});
+Deno.bench("baz", function () {});
diff --git a/tests/specs/bench/filter/b_bench.ts b/tests/specs/bench/filter/b_bench.ts
new file mode 100644
index 000000000..fc4ef859c
--- /dev/null
+++ b/tests/specs/bench/filter/b_bench.ts
@@ -0,0 +1,3 @@
+Deno.bench("foo", function () {});
+Deno.bench("bar", function () {});
+Deno.bench("baz", function () {});
diff --git a/tests/specs/bench/filter/c_bench.ts b/tests/specs/bench/filter/c_bench.ts
new file mode 100644
index 000000000..fc4ef859c
--- /dev/null
+++ b/tests/specs/bench/filter/c_bench.ts
@@ -0,0 +1,3 @@
+Deno.bench("foo", function () {});
+Deno.bench("bar", function () {});
+Deno.bench("baz", function () {});
diff --git a/tests/specs/bench/filter/filter.out b/tests/specs/bench/filter/filter.out
new file mode 100644
index 000000000..970171e0b
--- /dev/null
+++ b/tests/specs/bench/filter/filter.out
@@ -0,0 +1,20 @@
+Check [WILDCARD]/bench/filter/a_bench.ts
+Check [WILDCARD]/bench/filter/b_bench.ts
+Check [WILDCARD]/bench/filter/c_bench.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/bench/filter/a_bench.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+foo [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+
+[WILDCARD]/bench/filter/b_bench.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+foo [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+
+[WILDCARD]/bench/filter/c_bench.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+foo [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
diff --git a/tests/specs/bench/filter_group_header/main.out b/tests/specs/bench/filter_group_header/main.out
index efe157f6c..5791538fe 100644
--- a/tests/specs/bench/filter_group_header/main.out
+++ b/tests/specs/bench/filter_group_header/main.out
@@ -7,7 +7,7 @@ benchmark time (avg) iter/s (min … max) p75
--------------------------------------------------------------- -----------------------------
group G1
-G1-B [WILDCARD]
+G1-B [WILDCARD]
group G2
-G2-B [WILDCARD] \ No newline at end of file
+G2-B [WILDCARD] \ No newline at end of file
diff --git a/tests/specs/bench/finally_timeout/__test__.jsonc b/tests/specs/bench/finally_timeout/__test__.jsonc
new file mode 100644
index 000000000..621537204
--- /dev/null
+++ b/tests/specs/bench/finally_timeout/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench finally_timeout.ts",
+ "output": "finally_timeout.out",
+ "exitCode": 1
+}
diff --git a/tests/specs/bench/finally_timeout/finally_timeout.out b/tests/specs/bench/finally_timeout/finally_timeout.out
new file mode 100644
index 000000000..cefa18760
--- /dev/null
+++ b/tests/specs/bench/finally_timeout/finally_timeout.out
@@ -0,0 +1,11 @@
+Check [WILDCARD]/finally_timeout.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/finally_timeout.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+error error: Error: fail
+[WILDCARD]
+success [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+error: Bench failed
diff --git a/tests/specs/bench/finally_timeout/finally_timeout.ts b/tests/specs/bench/finally_timeout/finally_timeout.ts
new file mode 100644
index 000000000..c49eb8da2
--- /dev/null
+++ b/tests/specs/bench/finally_timeout/finally_timeout.ts
@@ -0,0 +1,11 @@
+Deno.bench("error", function () {
+ const timer = setTimeout(() => null, 10000);
+ try {
+ throw new Error("fail");
+ } finally {
+ clearTimeout(timer);
+ }
+});
+
+Deno.bench("success", function () {
+});
diff --git a/tests/specs/bench/group_baseline/__test__.jsonc b/tests/specs/bench/group_baseline/__test__.jsonc
new file mode 100644
index 000000000..5874b40c8
--- /dev/null
+++ b/tests/specs/bench/group_baseline/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench group_baseline.ts",
+ "output": "group_baseline.out",
+ "exitCode": 0
+}
diff --git a/tests/specs/bench/group_baseline/group_baseline.out b/tests/specs/bench/group_baseline/group_baseline.out
new file mode 100644
index 000000000..54a6cd359
--- /dev/null
+++ b/tests/specs/bench/group_baseline/group_baseline.out
@@ -0,0 +1,20 @@
+[WILDCARD]/group_baseline.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+-------------------------------------------------------------------- -----------------------------
+noop [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+noop2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+
+summary
+ noo[WILDCARD]
+ [WILDCARD]x [WILDCARD] than noo[WILDCARD]
+
+group url
+noop3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+parse url 2x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+parse url 200x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+
+summary
+ parse url 2x
+ [WILDCARD]x slower than noop3
+ [WILDCARD]x faster than parse url 200x
+
diff --git a/tests/specs/bench/group_baseline/group_baseline.ts b/tests/specs/bench/group_baseline/group_baseline.ts
new file mode 100644
index 000000000..a86f6455c
--- /dev/null
+++ b/tests/specs/bench/group_baseline/group_baseline.ts
@@ -0,0 +1,15 @@
+Deno.bench("noop", () => {});
+Deno.bench("noop2", { baseline: true }, () => {});
+
+Deno.bench("noop3", { group: "url" }, () => {});
+
+Deno.bench("parse url 2x", { group: "url", baseline: true }, () => {
+ new URL("https://deno.land/std/http/server.ts");
+ new URL("https://deno.land/std/http/server.ts");
+});
+
+Deno.bench("parse url 200x", { group: "url" }, () => {
+ for (let i = 0; i < 200; i++) {
+ new URL("https://deno.land/std/http/server.ts");
+ }
+});
diff --git a/tests/specs/bench/ignore/__test__.jsonc b/tests/specs/bench/ignore/__test__.jsonc
new file mode 100644
index 000000000..97053bb79
--- /dev/null
+++ b/tests/specs/bench/ignore/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench ignore.ts",
+ "output": "ignore.out",
+ "exitCode": 0
+}
diff --git a/tests/specs/bench/ignore/ignore.out b/tests/specs/bench/ignore/ignore.out
new file mode 100644
index 000000000..d74a0c181
--- /dev/null
+++ b/tests/specs/bench/ignore/ignore.out
@@ -0,0 +1,8 @@
+Check [WILDCARD]/ignore.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/ignore.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+
diff --git a/tests/specs/bench/ignore/ignore.ts b/tests/specs/bench/ignore/ignore.ts
new file mode 100644
index 000000000..0226fe76f
--- /dev/null
+++ b/tests/specs/bench/ignore/ignore.ts
@@ -0,0 +1,9 @@
+for (let i = 0; i < 10; i++) {
+ Deno.bench({
+ name: `bench${i}`,
+ ignore: true,
+ fn() {
+ throw new Error("unreachable");
+ },
+ });
+}
diff --git a/tests/specs/bench/ignore_permissions/__test__.jsonc b/tests/specs/bench/ignore_permissions/__test__.jsonc
new file mode 100644
index 000000000..592ab0240
--- /dev/null
+++ b/tests/specs/bench/ignore_permissions/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench ignore_permissions.ts",
+ "output": "ignore_permissions.out",
+ "exitCode": 0
+}
diff --git a/tests/specs/bench/ignore_permissions/ignore_permissions.out b/tests/specs/bench/ignore_permissions/ignore_permissions.out
new file mode 100644
index 000000000..eb577fecc
--- /dev/null
+++ b/tests/specs/bench/ignore_permissions/ignore_permissions.out
@@ -0,0 +1,8 @@
+Check [WILDCARD]/ignore_permissions.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/ignore_permissions.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+
diff --git a/tests/specs/bench/ignore_permissions/ignore_permissions.ts b/tests/specs/bench/ignore_permissions/ignore_permissions.ts
new file mode 100644
index 000000000..0dcd9299f
--- /dev/null
+++ b/tests/specs/bench/ignore_permissions/ignore_permissions.ts
@@ -0,0 +1,16 @@
+Deno.bench({
+ name: "ignore",
+ permissions: {
+ read: true,
+ write: true,
+ net: true,
+ env: true,
+ run: true,
+ ffi: true,
+ hrtime: true,
+ },
+ ignore: true,
+ fn() {
+ throw new Error("unreachable");
+ },
+});
diff --git a/tests/specs/bench/interval/__test__.jsonc b/tests/specs/bench/interval/__test__.jsonc
new file mode 100644
index 000000000..f4e89c1b5
--- /dev/null
+++ b/tests/specs/bench/interval/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench interval.ts",
+ "output": "interval.out",
+ "exitCode": 0
+}
diff --git a/tests/specs/bench/interval/interval.out b/tests/specs/bench/interval/interval.out
new file mode 100644
index 000000000..11e440940
--- /dev/null
+++ b/tests/specs/bench/interval/interval.out
@@ -0,0 +1,8 @@
+Check [WILDCARD]/interval.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/interval.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+
diff --git a/tests/specs/bench/interval/interval.ts b/tests/specs/bench/interval/interval.ts
new file mode 100644
index 000000000..7eb588c59
--- /dev/null
+++ b/tests/specs/bench/interval/interval.ts
@@ -0,0 +1 @@
+setInterval(function () {}, 0);
diff --git a/tests/specs/bench/json_output/__test__.jsonc b/tests/specs/bench/json_output/__test__.jsonc
new file mode 100644
index 000000000..fa0dadcd0
--- /dev/null
+++ b/tests/specs/bench/json_output/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench --json pass.ts",
+ "output": "pass.json.out",
+ "exitCode": 0
+}
diff --git a/tests/specs/bench/json_output/pass.json.out b/tests/specs/bench/json_output/pass.json.out
new file mode 100644
index 000000000..53259e758
--- /dev/null
+++ b/tests/specs/bench/json_output/pass.json.out
@@ -0,0 +1,28 @@
+Check file:///[WILDCARD]/pass.ts
+{
+ "runtime": "Deno/[WILDCARD]",
+ "cpu": "[WILDCARD]",
+ "benches": [
+ {
+ "origin": "file:///[WILDCARD]/pass.ts",
+ "group": null,
+ "name": "bench0",
+ "baseline": false,
+ "results": [
+ {
+ "ok": {
+ "n": [WILDCARD],
+ "min": [WILDCARD],
+ "max": [WILDCARD],
+ "avg": [WILDCARD],
+ "p75": [WILDCARD],
+ "p99": [WILDCARD],
+ "p995": [WILDCARD],
+ "p999": [WILDCARD]
+ }
+ }
+ ]
+ },
+[WILDCARD]
+ ]
+}
diff --git a/tests/specs/bench/json_output/pass.ts b/tests/specs/bench/json_output/pass.ts
new file mode 100644
index 000000000..48348d447
--- /dev/null
+++ b/tests/specs/bench/json_output/pass.ts
@@ -0,0 +1,10 @@
+Deno.bench("bench0", () => {});
+Deno.bench("bench1", () => {});
+Deno.bench("bench2", () => {});
+Deno.bench("bench3", () => {});
+Deno.bench("bench4", () => {});
+Deno.bench("bench5", () => {});
+Deno.bench("bench6", () => {});
+Deno.bench("bench7", () => {});
+Deno.bench("bench8", () => {});
+Deno.bench("bench9", () => {});
diff --git a/tests/specs/bench/load_unload/__test__.jsonc b/tests/specs/bench/load_unload/__test__.jsonc
new file mode 100644
index 000000000..8837d3d80
--- /dev/null
+++ b/tests/specs/bench/load_unload/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench load_unload.ts",
+ "output": "load_unload.out",
+ "exitCode": 0
+}
diff --git a/tests/specs/bench/load_unload/load_unload.out b/tests/specs/bench/load_unload/load_unload.out
new file mode 100644
index 000000000..99e4389ac
--- /dev/null
+++ b/tests/specs/bench/load_unload/load_unload.out
@@ -0,0 +1,8 @@
+Check [WILDCARD]/load_unload.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/load_unload.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+bench [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
diff --git a/tests/specs/bench/load_unload/load_unload.ts b/tests/specs/bench/load_unload/load_unload.ts
new file mode 100644
index 000000000..3653c135d
--- /dev/null
+++ b/tests/specs/bench/load_unload/load_unload.ts
@@ -0,0 +1,22 @@
+let interval: number | null = null;
+addEventListener("load", () => {
+ if (interval) {
+ throw new Error("Interval is already set");
+ }
+
+ interval = setInterval(() => {}, 0);
+});
+
+addEventListener("unload", () => {
+ if (!interval) {
+ throw new Error("Interval was not set");
+ }
+
+ clearInterval(interval);
+});
+
+Deno.bench("bench", () => {
+ if (!interval) {
+ throw new Error("Interval was not set");
+ }
+});
diff --git a/tests/specs/bench/meta/__test__.jsonc b/tests/specs/bench/meta/__test__.jsonc
new file mode 100644
index 000000000..10a4ff3a4
--- /dev/null
+++ b/tests/specs/bench/meta/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench meta.ts",
+ "output": "meta.out",
+ "exitCode": 0
+}
diff --git a/tests/specs/bench/meta/meta.out b/tests/specs/bench/meta/meta.out
new file mode 100644
index 000000000..75a75984e
--- /dev/null
+++ b/tests/specs/bench/meta/meta.out
@@ -0,0 +1,10 @@
+Check [WILDCARD]/meta.ts
+import.meta.main: false
+import.meta.url: [WILDCARD]/meta.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/meta.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+
diff --git a/tests/specs/bench/meta/meta.ts b/tests/specs/bench/meta/meta.ts
new file mode 100644
index 000000000..e32fdeea6
--- /dev/null
+++ b/tests/specs/bench/meta/meta.ts
@@ -0,0 +1,2 @@
+console.log("import.meta.main: %s", import.meta.main);
+console.log("import.meta.url: %s", import.meta.url);
diff --git a/tests/specs/bench/multifile_summary/__test__.jsonc b/tests/specs/bench/multifile_summary/__test__.jsonc
new file mode 100644
index 000000000..757af150b
--- /dev/null
+++ b/tests/specs/bench/multifile_summary/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench group_baseline.ts pass.ts multiple_group.ts",
+ "output": "multifile_summary.out",
+ "exitCode": 0
+}
diff --git a/tests/specs/bench/multifile_summary/group_baseline.ts b/tests/specs/bench/multifile_summary/group_baseline.ts
new file mode 100644
index 000000000..a86f6455c
--- /dev/null
+++ b/tests/specs/bench/multifile_summary/group_baseline.ts
@@ -0,0 +1,15 @@
+Deno.bench("noop", () => {});
+Deno.bench("noop2", { baseline: true }, () => {});
+
+Deno.bench("noop3", { group: "url" }, () => {});
+
+Deno.bench("parse url 2x", { group: "url", baseline: true }, () => {
+ new URL("https://deno.land/std/http/server.ts");
+ new URL("https://deno.land/std/http/server.ts");
+});
+
+Deno.bench("parse url 200x", { group: "url" }, () => {
+ for (let i = 0; i < 200; i++) {
+ new URL("https://deno.land/std/http/server.ts");
+ }
+});
diff --git a/tests/specs/bench/multifile_summary/multifile_summary.out b/tests/specs/bench/multifile_summary/multifile_summary.out
new file mode 100644
index 000000000..c0439ebba
--- /dev/null
+++ b/tests/specs/bench/multifile_summary/multifile_summary.out
@@ -0,0 +1,64 @@
+Check [WILDCARD]/group_baseline.ts
+Check [WILDCARD]/pass.ts
+Check [WILDCARD]/multiple_group.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/group_baseline.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+-------------------------------------------------------------------- -----------------------------
+noop [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+noop2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+
+summary
+ noo[WILDCARD]
+ [WILDCARD]x [WILDCARD] than noo[WILDCARD]
+
+group url
+noop3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+parse url 2x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+parse url 200x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+
+summary
+ parse url 2x
+ [WILDLINE]x slower than noop3
+ [WILDLINE]x faster than parse url 200x
+
+
+[WILDLINE]/pass.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+bench0 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench1 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench4 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench5 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench6 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench7 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench8 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench9 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+
+
+[WILDLINE]/multiple_group.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+-------------------------------------------------------------------- -----------------------------
+
+group noop
+noop [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+noop2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+
+summary
+ noo[WILDCARD]
+ [WILDCARD]x [WILDCARD] than noo[WILDCARD]
+
+group url
+noop3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+parse url 2x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+parse url 200x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+
+summary
+ parse url 2x
+ [WILDCARD]x slower than noop3
+ [WILDCARD]x faster than parse url 200x
+
diff --git a/tests/specs/bench/multifile_summary/multiple_group.ts b/tests/specs/bench/multifile_summary/multiple_group.ts
new file mode 100644
index 000000000..165b5e201
--- /dev/null
+++ b/tests/specs/bench/multifile_summary/multiple_group.ts
@@ -0,0 +1,15 @@
+Deno.bench("noop", { group: "noop" }, () => {});
+Deno.bench("noop2", { group: "noop", baseline: true }, () => {});
+
+Deno.bench("noop3", { group: "url" }, () => {});
+
+Deno.bench("parse url 2x", { group: "url", baseline: true }, () => {
+ new URL("https://jsr.io/@std/http/0.221.0/file_server.ts");
+ new URL("https://jsr.io/@std/http/0.221.0/file_server.ts");
+});
+
+Deno.bench("parse url 200x", { group: "url" }, () => {
+ for (let i = 0; i < 200; i++) {
+ new URL("https://jsr.io/@std/http/0.221.0/file_server.ts");
+ }
+});
diff --git a/tests/specs/bench/multifile_summary/pass.ts b/tests/specs/bench/multifile_summary/pass.ts
new file mode 100644
index 000000000..48348d447
--- /dev/null
+++ b/tests/specs/bench/multifile_summary/pass.ts
@@ -0,0 +1,10 @@
+Deno.bench("bench0", () => {});
+Deno.bench("bench1", () => {});
+Deno.bench("bench2", () => {});
+Deno.bench("bench3", () => {});
+Deno.bench("bench4", () => {});
+Deno.bench("bench5", () => {});
+Deno.bench("bench6", () => {});
+Deno.bench("bench7", () => {});
+Deno.bench("bench8", () => {});
+Deno.bench("bench9", () => {});
diff --git a/tests/specs/bench/no_check/__test__.jsonc b/tests/specs/bench/no_check/__test__.jsonc
new file mode 100644
index 000000000..d031e52de
--- /dev/null
+++ b/tests/specs/bench/no_check/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench --no-check no_check.ts",
+ "output": "no_check.out",
+ "exitCode": 1
+}
diff --git a/tests/specs/bench/no_check/no_check.out b/tests/specs/bench/no_check/no_check.out
new file mode 100644
index 000000000..c373c812c
--- /dev/null
+++ b/tests/specs/bench/no_check/no_check.out
@@ -0,0 +1,9 @@
+error: (in promise) TypeError: Cannot read properties of undefined (reading 'fn')
+Deno.bench();
+ ^
+ at [WILDCARD]
+ at [WILDCARD]/no_check.ts:1:6
+This error was not caught from a benchmark and caused the bench runner to fail on the referenced module.
+It most likely originated from a dangling promise, event/timeout handler or top-level code.
+
+error: Bench failed
diff --git a/tests/specs/bench/no_check/no_check.ts b/tests/specs/bench/no_check/no_check.ts
new file mode 100644
index 000000000..b159cabd6
--- /dev/null
+++ b/tests/specs/bench/no_check/no_check.ts
@@ -0,0 +1 @@
+Deno.bench();
diff --git a/tests/specs/bench/no_prompt_by_default/__test__.jsonc b/tests/specs/bench/no_prompt_by_default/__test__.jsonc
new file mode 100644
index 000000000..e3f4127da
--- /dev/null
+++ b/tests/specs/bench/no_prompt_by_default/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench --quiet no_prompt_by_default.ts",
+ "output": "no_prompt_by_default.out",
+ "exitCode": 1
+}
diff --git a/tests/specs/bench/no_prompt_by_default/no_prompt_by_default.out b/tests/specs/bench/no_prompt_by_default/no_prompt_by_default.out
new file mode 100644
index 000000000..7c5f2b5c2
--- /dev/null
+++ b/tests/specs/bench/no_prompt_by_default/no_prompt_by_default.out
@@ -0,0 +1,9 @@
+[WILDCARD]cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/no_prompt_by_default.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+no prompt error: PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag
+[WILDCARD]
+error: Bench failed
diff --git a/tests/specs/bench/no_prompt_by_default/no_prompt_by_default.ts b/tests/specs/bench/no_prompt_by_default/no_prompt_by_default.ts
new file mode 100644
index 000000000..59359eebd
--- /dev/null
+++ b/tests/specs/bench/no_prompt_by_default/no_prompt_by_default.ts
@@ -0,0 +1,3 @@
+Deno.bench("no prompt", async () => {
+ await Deno.readTextFile("./some_file.txt");
+});
diff --git a/tests/specs/bench/no_prompt_with_denied_perms/__test__.jsonc b/tests/specs/bench/no_prompt_with_denied_perms/__test__.jsonc
new file mode 100644
index 000000000..a06645249
--- /dev/null
+++ b/tests/specs/bench/no_prompt_with_denied_perms/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench --quiet --allow-read no_prompt_with_denied_perms.ts",
+ "output": "no_prompt_with_denied_perms.out",
+ "exitCode": 1
+}
diff --git a/tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.out b/tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.out
new file mode 100644
index 000000000..bbdd2ac46
--- /dev/null
+++ b/tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.out
@@ -0,0 +1,9 @@
+[WILDCARD]cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/no_prompt_with_denied_perms.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+no prompt error: PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag
+[WILDCARD]
+error: Bench failed
diff --git a/tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.ts b/tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.ts
new file mode 100644
index 000000000..2f0d63bbe
--- /dev/null
+++ b/tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.ts
@@ -0,0 +1,3 @@
+Deno.bench("no prompt", { permissions: { read: false } }, async () => {
+ await Deno.readTextFile("./some_file.txt");
+});
diff --git a/tests/specs/bench/no_run/__test__.jsonc b/tests/specs/bench/no_run/__test__.jsonc
new file mode 100644
index 000000000..159f6fd5a
--- /dev/null
+++ b/tests/specs/bench/no_run/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench --no-run no_run.ts",
+ "output": "no_run.out",
+ "exitCode": 1
+}
diff --git a/tests/specs/bench/no_run/no_run.out b/tests/specs/bench/no_run/no_run.out
new file mode 100644
index 000000000..77ce18366
--- /dev/null
+++ b/tests/specs/bench/no_run/no_run.out
@@ -0,0 +1,5 @@
+Check [WILDCARD]/no_run.ts
+error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'.
+const _value: string = 1;
+ ~~~~~~
+ at [WILDCARD]/no_run.ts:1:7
diff --git a/tests/specs/bench/no_run/no_run.ts b/tests/specs/bench/no_run/no_run.ts
new file mode 100644
index 000000000..c7a5dc1e8
--- /dev/null
+++ b/tests/specs/bench/no_run/no_run.ts
@@ -0,0 +1,2 @@
+const _value: string = 1;
+console.log("this should not be run");
diff --git a/tests/specs/bench/only/__test__.jsonc b/tests/specs/bench/only/__test__.jsonc
new file mode 100644
index 000000000..7d50a6dec
--- /dev/null
+++ b/tests/specs/bench/only/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench only.ts",
+ "output": "only.out",
+ "exitCode": 1
+}
diff --git a/tests/specs/bench/only/only.out b/tests/specs/bench/only/only.out
new file mode 100644
index 000000000..e3332d174
--- /dev/null
+++ b/tests/specs/bench/only/only.out
@@ -0,0 +1,9 @@
+Check [WILDCARD]/only.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/only.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+only [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+error: Bench failed because the "only" option was used
diff --git a/tests/specs/bench/only/only.ts b/tests/specs/bench/only/only.ts
new file mode 100644
index 000000000..0129c024c
--- /dev/null
+++ b/tests/specs/bench/only/only.ts
@@ -0,0 +1,15 @@
+Deno.bench({
+ name: "before",
+ fn() {},
+});
+
+Deno.bench({
+ only: true,
+ name: "only",
+ fn() {},
+});
+
+Deno.bench({
+ name: "after",
+ fn() {},
+});
diff --git a/tests/specs/bench/overloads/__test__.jsonc b/tests/specs/bench/overloads/__test__.jsonc
new file mode 100644
index 000000000..ae0fe0a07
--- /dev/null
+++ b/tests/specs/bench/overloads/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench overloads.ts",
+ "output": "overloads.out",
+ "exitCode": 0
+}
diff --git a/tests/specs/bench/overloads/overloads.out b/tests/specs/bench/overloads/overloads.out
new file mode 100644
index 000000000..21f8759dd
--- /dev/null
+++ b/tests/specs/bench/overloads/overloads.out
@@ -0,0 +1,12 @@
+Check [WILDCARD]/overloads.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/overloads.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+bench0 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench1 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench4 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
diff --git a/tests/specs/bench/overloads/overloads.ts b/tests/specs/bench/overloads/overloads.ts
new file mode 100644
index 000000000..4f5887f79
--- /dev/null
+++ b/tests/specs/bench/overloads/overloads.ts
@@ -0,0 +1,6 @@
+Deno.bench("bench0", () => {});
+Deno.bench(function bench1() {});
+Deno.bench({ name: "bench2", fn: () => {} });
+Deno.bench("bench3", { permissions: "none" }, () => {});
+Deno.bench({ name: "bench4" }, () => {});
+Deno.bench({ ignore: true }, function bench5() {});
diff --git a/tests/specs/bench/package_json/__test__.jsonc b/tests/specs/bench/package_json/__test__.jsonc
new file mode 100644
index 000000000..001cc8b54
--- /dev/null
+++ b/tests/specs/bench/package_json/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "tempDir": true,
+ "args": "bench",
+ "output": "lib.bench.out"
+}
diff --git a/tests/specs/bench/package_json/lib.bench.out b/tests/specs/bench/package_json/lib.bench.out
new file mode 100644
index 000000000..fa9c5efc6
--- /dev/null
+++ b/tests/specs/bench/package_json/lib.bench.out
@@ -0,0 +1,11 @@
+Download http://localhost:4545/npm/registry/@denotest/esm-basic
+Download http://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz
+Initialize @denotest/esm-basic@1.0.0
+Check file:///[WILDCARD]/lib.bench.ts
+cpu: [WILDCARD]
+runtime: [WILDCARD]
+
+file:///[WILDCARD]/lib.bench.ts
+[WILDCARD]
+---------------------------------------------------------------- -----------------------------
+should add [WILDCARD]
diff --git a/tests/specs/bench/package_json/lib.bench.ts b/tests/specs/bench/package_json/lib.bench.ts
new file mode 100644
index 000000000..e6b79d025
--- /dev/null
+++ b/tests/specs/bench/package_json/lib.bench.ts
@@ -0,0 +1,7 @@
+import { add } from "./lib.ts";
+
+Deno.bench("should add", () => {
+ if (add(1, 2) !== 3) {
+ throw new Error("Fail");
+ }
+});
diff --git a/tests/specs/bench/package_json/lib.ts b/tests/specs/bench/package_json/lib.ts
new file mode 100644
index 000000000..1deed81f7
--- /dev/null
+++ b/tests/specs/bench/package_json/lib.ts
@@ -0,0 +1,9 @@
+import * as test from "@denotest/esm-basic";
+
+export function add(a: number, b: number) {
+ return a + b;
+}
+
+export function getValue() {
+ return test.getValue();
+}
diff --git a/tests/specs/bench/package_json/package.json b/tests/specs/bench/package_json/package.json
new file mode 100644
index 000000000..54ca824d6
--- /dev/null
+++ b/tests/specs/bench/package_json/package.json
@@ -0,0 +1,5 @@
+{
+ "dependencies": {
+ "@denotest/esm-basic": "*"
+ }
+}
diff --git a/tests/specs/bench/pass/__test__.jsonc b/tests/specs/bench/pass/__test__.jsonc
new file mode 100644
index 000000000..797684ec6
--- /dev/null
+++ b/tests/specs/bench/pass/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench pass.ts",
+ "output": "pass.out",
+ "exitCode": 0
+}
diff --git a/tests/specs/bench/pass/pass.out b/tests/specs/bench/pass/pass.out
new file mode 100644
index 000000000..4be2b8723
--- /dev/null
+++ b/tests/specs/bench/pass/pass.out
@@ -0,0 +1,17 @@
+Check [WILDCARD]/pass.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/pass.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+--------------------------------------------------------------- -----------------------------
+bench0 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench1 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench4 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench5 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench6 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench7 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench8 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench9 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
diff --git a/tests/specs/bench/pass/pass.ts b/tests/specs/bench/pass/pass.ts
new file mode 100644
index 000000000..48348d447
--- /dev/null
+++ b/tests/specs/bench/pass/pass.ts
@@ -0,0 +1,10 @@
+Deno.bench("bench0", () => {});
+Deno.bench("bench1", () => {});
+Deno.bench("bench2", () => {});
+Deno.bench("bench3", () => {});
+Deno.bench("bench4", () => {});
+Deno.bench("bench5", () => {});
+Deno.bench("bench6", () => {});
+Deno.bench("bench7", () => {});
+Deno.bench("bench8", () => {});
+Deno.bench("bench9", () => {});
diff --git a/tests/specs/bench/quiet/__test__.jsonc b/tests/specs/bench/quiet/__test__.jsonc
new file mode 100644
index 000000000..a220e9936
--- /dev/null
+++ b/tests/specs/bench/quiet/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench --quiet quiet.ts",
+ "output": "quiet.out",
+ "exitCode": 0
+}
diff --git a/tests/specs/bench/quiet/quiet.out b/tests/specs/bench/quiet/quiet.out
new file mode 100644
index 000000000..fa9166d65
--- /dev/null
+++ b/tests/specs/bench/quiet/quiet.out
@@ -0,0 +1,10 @@
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/quiet.ts
+benchmark time (avg) iter/s (min … max) p75 p99 p995
+------------------------------------------------------------------- -----------------------------
+console.log [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+console.error [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+console.info [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+console.warn [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
diff --git a/tests/specs/bench/quiet/quiet.ts b/tests/specs/bench/quiet/quiet.ts
new file mode 100644
index 000000000..efeb366ff
--- /dev/null
+++ b/tests/specs/bench/quiet/quiet.ts
@@ -0,0 +1,15 @@
+Deno.bench("console.log", function () {
+ console.log("log");
+});
+
+Deno.bench("console.error", function () {
+ console.error("error");
+});
+
+Deno.bench("console.info", function () {
+ console.info("info");
+});
+
+Deno.bench("console.warn", function () {
+ console.info("warn");
+});
diff --git a/tests/specs/bench/unhandled_rejection/__test__.jsonc b/tests/specs/bench/unhandled_rejection/__test__.jsonc
new file mode 100644
index 000000000..0576136ef
--- /dev/null
+++ b/tests/specs/bench/unhandled_rejection/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench unhandled_rejection.ts",
+ "output": "unhandled_rejection.out",
+ "exitCode": 1
+}
diff --git a/tests/specs/bench/unhandled_rejection/unhandled_rejection.out b/tests/specs/bench/unhandled_rejection/unhandled_rejection.out
new file mode 100644
index 000000000..b95b9ab8b
--- /dev/null
+++ b/tests/specs/bench/unhandled_rejection/unhandled_rejection.out
@@ -0,0 +1,11 @@
+Check [WILDCARD]/unhandled_rejection.ts
+error: (in promise) Error: rejection
+ reject(new Error("rejection"));
+ ^
+ at [WILDCARD]/unhandled_rejection.ts:2:10
+ at new Promise (<anonymous>)
+ at [WILDCARD]/unhandled_rejection.ts:1:1
+This error was not caught from a benchmark and caused the bench runner to fail on the referenced module.
+It most likely originated from a dangling promise, event/timeout handler or top-level code.
+
+error: Bench failed
diff --git a/tests/specs/bench/unhandled_rejection/unhandled_rejection.ts b/tests/specs/bench/unhandled_rejection/unhandled_rejection.ts
new file mode 100644
index 000000000..32f3111ea
--- /dev/null
+++ b/tests/specs/bench/unhandled_rejection/unhandled_rejection.ts
@@ -0,0 +1,3 @@
+new Promise((_resolve, reject) => {
+ reject(new Error("rejection"));
+});
diff --git a/tests/specs/bench/unresolved_promise/__test__.jsonc b/tests/specs/bench/unresolved_promise/__test__.jsonc
new file mode 100644
index 000000000..487e46b3d
--- /dev/null
+++ b/tests/specs/bench/unresolved_promise/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "bench unresolved_promise.ts",
+ "output": "unresolved_promise.out",
+ "exitCode": 1
+}
diff --git a/tests/specs/bench/unresolved_promise/unresolved_promise.out b/tests/specs/bench/unresolved_promise/unresolved_promise.out
new file mode 100644
index 000000000..92d29f399
--- /dev/null
+++ b/tests/specs/bench/unresolved_promise/unresolved_promise.out
@@ -0,0 +1,9 @@
+Check [WILDCARD]/unresolved_promise.ts
+error: Top-level await promise never resolved
+await new Promise((_resolve, _reject) => {});
+^
+ at <anonymous> ([WILDCARD]/unresolved_promise.ts:1:1)
+This error was not caught from a benchmark and caused the bench runner to fail on the referenced module.
+It most likely originated from a dangling promise, event/timeout handler or top-level code.
+
+error: Bench failed
diff --git a/tests/specs/bench/unresolved_promise/unresolved_promise.ts b/tests/specs/bench/unresolved_promise/unresolved_promise.ts
new file mode 100644
index 000000000..25fe70762
--- /dev/null
+++ b/tests/specs/bench/unresolved_promise/unresolved_promise.ts
@@ -0,0 +1 @@
+await new Promise((_resolve, _reject) => {});