Skip to content

Commit

Permalink
added plotting via Observable Plot and JSDOM
Browse files Browse the repository at this point in the history
  • Loading branch information
John Owens committed Nov 6, 2024
1 parent 4391167 commit 2030526
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion both_webgpu/both_node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const require = createRequire(import.meta.url);
const dawn = require("../../../src/dawn-build/dawn.node");
Object.assign(globalThis, dawn.globals); // Provides constants like GPUBufferUsage.MAP_READ

import * as Plot from "@observablehq/plot";
import { JSDOM } from "jsdom";

let navigator = {
gpu: dawn.create(["enable-dawn-features=use_user_defined_labels_in_backend"]),
};
Expand All @@ -19,4 +22,28 @@ if (typeof process !== "undefined" && process.release.name === "node") {
alert("Use this only in Node.");
}

main(navigator);
const data = await main(navigator);
console.log(data);
const plot = Plot.plot({
document: new JSDOM("").window.document,
marks: [
Plot.lineY(data, {
x: "bytesTransferred",
y: "bandwidth",
stroke: "workgroupSize",
}),
],
});

plot.setAttributeNS(
"http://www.w3.org/2000/xmlns/",
"xmlns",
"http://www.w3.org/2000/svg"
);
plot.setAttributeNS(
"http://www.w3.org/2000/xmlns/",
"xmlns:xlink",
"http://www.w3.org/1999/xlink"
);

process.stdout.write(plot.outerHTML);

0 comments on commit 2030526

Please sign in to comment.