summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-11-18 15:09:28 -0500
committerGitHub <noreply@github.com>2024-11-18 20:09:28 +0000
commitdd4570ed85888d9659a2eec98437dbd6de4a5799 (patch)
tree0880f06e3b0f51267ad6e1619941dcc07c5c14c6 /tests
parent3ba464dbc40dd2d6bd3f7a1912aa8f0fad95058f (diff)
perf(compile): code cache (#26528)
Adds a lazily created code cache to `deno compile` by default. The code cache is created on first run to a single file in the temp directory and is only written once. After it's been written, the code cache becomes read only on subsequent runs. Only the modules loaded during startup are cached (dynamic imports are not code cached). The code cache can be disabled by compiling with `--no-code-cache`.
Diffstat (limited to 'tests')
-rw-r--r--tests/specs/compile/code_cache/__test__.jsonc32
-rw-r--r--tests/specs/compile/code_cache/first_run.out1
-rw-r--r--tests/specs/compile/code_cache/main.ts3
-rw-r--r--tests/specs/compile/code_cache/second_run.out1
-rw-r--r--tests/specs/compile/no_code_cache/__test__.jsonc22
-rw-r--r--tests/specs/compile/no_code_cache/main.out1
-rw-r--r--tests/specs/compile/no_code_cache/main.ts3
7 files changed, 63 insertions, 0 deletions
diff --git a/tests/specs/compile/code_cache/__test__.jsonc b/tests/specs/compile/code_cache/__test__.jsonc
new file mode 100644
index 000000000..72353e27d
--- /dev/null
+++ b/tests/specs/compile/code_cache/__test__.jsonc
@@ -0,0 +1,32 @@
+{
+ "tempDir": true,
+ "steps": [{
+ "if": "unix",
+ "args": "compile --output using_code_cache --log-level=debug main.ts",
+ "output": "[WILDCARD]"
+ }, {
+ "if": "unix",
+ "commandName": "./using_code_cache",
+ "args": [],
+ "output": "first_run.out"
+ }, {
+ "if": "unix",
+ "commandName": "./using_code_cache",
+ "args": [],
+ "output": "second_run.out"
+ }, {
+ "if": "windows",
+ "args": "compile --output using_code_cache.exe --log-level=debug main.ts",
+ "output": "[WILDCARD]"
+ }, {
+ "if": "windows",
+ "commandName": "./using_code_cache.exe",
+ "args": [],
+ "output": "first_run.out"
+ }, {
+ "if": "windows",
+ "commandName": "./using_code_cache.exe",
+ "args": [],
+ "output": "second_run.out"
+ }]
+}
diff --git a/tests/specs/compile/code_cache/first_run.out b/tests/specs/compile/code_cache/first_run.out
new file mode 100644
index 000000000..ca13e088f
--- /dev/null
+++ b/tests/specs/compile/code_cache/first_run.out
@@ -0,0 +1 @@
+[WILDCARD]Serialized 9 code cache entries[WILDCARD] \ No newline at end of file
diff --git a/tests/specs/compile/code_cache/main.ts b/tests/specs/compile/code_cache/main.ts
new file mode 100644
index 000000000..b1d552d30
--- /dev/null
+++ b/tests/specs/compile/code_cache/main.ts
@@ -0,0 +1,3 @@
+import { join } from "jsr:@std/url@0.220/join";
+
+console.log(join);
diff --git a/tests/specs/compile/code_cache/second_run.out b/tests/specs/compile/code_cache/second_run.out
new file mode 100644
index 000000000..5f6afcf7e
--- /dev/null
+++ b/tests/specs/compile/code_cache/second_run.out
@@ -0,0 +1 @@
+[WILDCARD]Loaded 9 code cache entries[WILDCARD][Function: join][WILDCARD] \ No newline at end of file
diff --git a/tests/specs/compile/no_code_cache/__test__.jsonc b/tests/specs/compile/no_code_cache/__test__.jsonc
new file mode 100644
index 000000000..2589054ec
--- /dev/null
+++ b/tests/specs/compile/no_code_cache/__test__.jsonc
@@ -0,0 +1,22 @@
+{
+ "tempDir": true,
+ "steps": [{
+ "if": "unix",
+ "args": "compile --output no_code_cache --no-code-cache --log-level=debug main.ts",
+ "output": "[WILDCARD]"
+ }, {
+ "if": "unix",
+ "commandName": "./no_code_cache",
+ "args": [],
+ "output": "main.out"
+ }, {
+ "if": "windows",
+ "args": "compile --output no_code_cache.exe --no-code-cache --log-level=debug main.ts",
+ "output": "[WILDCARD]"
+ }, {
+ "if": "windows",
+ "commandName": "./no_code_cache.exe",
+ "args": [],
+ "output": "main.out"
+ }]
+}
diff --git a/tests/specs/compile/no_code_cache/main.out b/tests/specs/compile/no_code_cache/main.out
new file mode 100644
index 000000000..e91f13282
--- /dev/null
+++ b/tests/specs/compile/no_code_cache/main.out
@@ -0,0 +1 @@
+[WILDCARD]Code cache disabled.[WILDCARD] \ No newline at end of file
diff --git a/tests/specs/compile/no_code_cache/main.ts b/tests/specs/compile/no_code_cache/main.ts
new file mode 100644
index 000000000..b1d552d30
--- /dev/null
+++ b/tests/specs/compile/no_code_cache/main.ts
@@ -0,0 +1,3 @@
+import { join } from "jsr:@std/url@0.220/join";
+
+console.log(join);