summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/bench/README.md33
-rw-r--r--tools/bench/mod.js4
-rw-r--r--tools/bench/rebench.js27
-rw-r--r--tools/bench/rebootstrap.js27
-rwxr-xr-xtools/wgpu_sync.js12
5 files changed, 12 insertions, 91 deletions
diff --git a/tools/bench/README.md b/tools/bench/README.md
deleted file mode 100644
index 78529d106..000000000
--- a/tools/bench/README.md
+++ /dev/null
@@ -1,33 +0,0 @@
-## Re-bootstrapping
-
-Re-bootstrapping allows deno devs to bench/profile/test JS-side changes without
-doing a full `cargo build --release --bin deno` which takes roughly ~4mn on M1s
-more on other machines which significantly slows down iteration &
-experimentation.
-
-## Example
-
-```js
-import { benchSync, rebootstrap } from "./tools/bench/mod.js";
-
-const bootstrap = rebootstrap([
- "webidl",
- "console",
- "url",
- "web",
- "fetch",
-]);
-
-benchSync("resp_w_h", 1e6, () =>
- new bootstrap.fetch.Response("yolo", {
- status: 200,
- headers: {
- server: "deno",
- "content-type": "text/plain",
- },
- }));
-```
-
-This code can then benched and profiled (using Chrome's DevTools) similar to
-regular userland code and the original source files appear in the DevTools as
-you would expect.
diff --git a/tools/bench/mod.js b/tools/bench/mod.js
deleted file mode 100644
index 9d90818a5..000000000
--- a/tools/bench/mod.js
+++ /dev/null
@@ -1,4 +0,0 @@
-// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-
-export * from "./rebench.js";
-export * from "./rebootstrap.js";
diff --git a/tools/bench/rebench.js b/tools/bench/rebench.js
deleted file mode 100644
index 7d77a79cd..000000000
--- a/tools/bench/rebench.js
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-
-export function benchSync(name, n, innerLoop) {
- const t1 = Date.now();
- for (let i = 0; i < n; i++) {
- innerLoop(i);
- }
- const t2 = Date.now();
- console.log(benchStats(name, n, t1, t2));
-}
-
-export async function benchAsync(name, n, innerLoop) {
- const t1 = Date.now();
- for (let i = 0; i < n; i++) {
- await innerLoop(i);
- }
- const t2 = Date.now();
- console.log(benchStats(name, n, t1, t2));
-}
-
-function benchStats(name, n, t1, t2) {
- const dt = (t2 - t1) / 1e3;
- const r = n / dt;
- const ns = Math.floor(dt / n * 1e9);
- return `${name}:${" ".repeat(20 - name.length)}\t` +
- `n = ${n}, dt = ${dt.toFixed(3)}s, r = ${r.toFixed(0)}/s, t = ${ns}ns/op`;
-}
diff --git a/tools/bench/rebootstrap.js b/tools/bench/rebootstrap.js
deleted file mode 100644
index 0e94285d5..000000000
--- a/tools/bench/rebootstrap.js
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-
-import { dirname, fromFileUrl, join } from "../../test_util/std/path/mod.ts";
-import { expandGlobSync } from "../../test_util/std/fs/mod.ts";
-
-const ROOT_DIR = join(dirname(fromFileUrl(import.meta.url)), "..", "..");
-
-export function rebootstrap(exts) {
- [
- "core/00_primordials.js",
- ...exts.map((e) => `ext/${e}/*.js`),
- ]
- .map((pattern) => join(ROOT_DIR, pattern))
- .map((pattern) => [...expandGlobSync(pattern)])
- .flat()
- .map((entry) => entry.path)
- .forEach((file) => {
- Deno.core.evalContext(Deno.readTextFileSync(file), file);
- });
- const bootstrap = globalThis.__bootstrap;
- delete globalThis.__bootstrap;
- // Patch dispatchEvent so we don't crash when MainWorker exits via:
- // `window.dispatchEvent(new Event('unload'))`
- // which fails since symbols are mangled during rebootstrap
- globalThis.dispatchEvent = () => {};
- return bootstrap;
-}
diff --git a/tools/wgpu_sync.js b/tools/wgpu_sync.js
index 6edc4c92f..4d14f43cf 100755
--- a/tools/wgpu_sync.js
+++ b/tools/wgpu_sync.js
@@ -92,11 +92,23 @@ async function patchSrcLib() {
);
}
+async function patchSurface() {
+ await patchFile(
+ join(TARGET_DIR, "src", "surface.rs"),
+ (data) =>
+ data.replace(
+ `prefix "internal:deno_webgpu",`,
+ `prefix "internal:ext/webgpu",`,
+ ),
+ );
+}
+
async function main() {
await clearTargetDir();
await checkoutUpstream();
await patchCargo();
await patchSrcLib();
+ await patchSurface();
await bash(join(ROOT_PATH, "tools", "format.js"));
}