Last active
November 17, 2025 09:14
-
-
Save greggman/776ed19ec60fa86e08882fd1d8beb8a7 to your computer and use it in GitHub Desktop.
WebGPU: Lots of resources
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*bug-in-github-api-content-can-not-be-empty*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*bug-in-github-api-content-can-not-be-empty*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function main() { | |
| const adapter = await navigator.gpu.requestAdapter(); | |
| const device = await adapter.requestDevice(); | |
| const kNumPerStep = 128 * 1024; | |
| let count = 0; | |
| for (;;) { | |
| const startTime = performance.now(); | |
| for (let i = 0; i < kNumPerStep; ++i) { | |
| const buffer = device.createBuffer({size: 16, usage: GPUBufferUsage.STORAGE}); | |
| buffer.destroy(); | |
| } | |
| device.queue.submit([]); | |
| await device.queue.onSubmittedWorkDone(); | |
| const endTime = performance.now(); | |
| const duration = endTime - startTime; | |
| count += kNumPerStep; | |
| console.log(`count: ${count.toString().padEnd(10)}, duration: ${duration.toFixed(8)}ms, time per creation: ${(duration / kNumPerStep).toFixed(8)}ms`); | |
| } | |
| } | |
| main(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"name":"WebGPU: Lots of resources","settings":{},"filenames":["index.html","index.css","index.js"]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment