Skip to content

Commit f7e1790

Browse files
authored
feat(ext/web): Performance
feat(ext/web): Performance
2 parents 57ed0a8 + 67eb10c commit f7e1790

File tree

8 files changed

+1660
-71
lines changed

8 files changed

+1660
-71
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ clap = { version = "4.5.39", features = ["derive"] }
1919
console = "0.15.8"
2020
image = "0.25.5"
2121
libsui = "0.10.0"
22-
nova_vm = { git = "https://github.com/trynova/nova", rev = "76688c29a4d9f8ab1d9ad42ba79485366ca3ed75", features = [
22+
nova_vm = { git = "https://github.com/trynova/nova", rev = "2f09304d915a3157e73ffc4a7f48bbd34aad3844", features = [
2323
"typescript"
2424
] }
2525
nu-ansi-term = "0.50.0"

examples/performance.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function measureFn<T>(fn: () => T, name: string): T {
2+
performance.mark(`${name}-start`);
3+
const result = fn();
4+
performance.mark(`${name}-end`);
5+
performance.measure(name, `${name}-start`, `${name}-end`);
6+
7+
const measure = performance.getEntriesByName(name)[0];
8+
console.log(`${measure.name}: ${measure.duration.toFixed(2)} ms`);
9+
10+
return result;
11+
}
12+
13+
for (let i = 0; i < 100; i++) {
14+
console.log(`Iteration ${i}: ${measureFn(() => i * i, `Square of ${i}`)}`);
15+
}

0 commit comments

Comments
 (0)