From f7b26b5c0d48d8e30a409a39050f98a03e89db87 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sun, 19 Jan 2025 22:41:23 -0800 Subject: [PATCH] Log mapAsync times and remove validation for more accurate comparison testing. --- benchmarks.md | 2 ++ src/classes/gpu.ts | 3 +++ test.html | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/benchmarks.md b/benchmarks.md index 69903fa..f8aeb9d 100644 --- a/benchmarks.md +++ b/benchmarks.md @@ -5,6 +5,8 @@ SPDX-License-Identifier: GPL-3.0-or-later Zero threshold benchmark (vectors) +16.0569471600238 average on 512 when logging mapAsync only + { "NanoPow (WebGPU) | Effort: 8 | Dispatch: 4194304 | Threads: 268435456": { "count": 512, diff --git a/src/classes/gpu.ts b/src/classes/gpu.ts index 36937bb..e038f51 100644 --- a/src/classes/gpu.ts +++ b/src/classes/gpu.ts @@ -182,8 +182,11 @@ export class NanoPowGpu { // Read results back to Javascript and then unmap buffer after reading let data = null + let start try { + start = performance.now() await this.#cpuBuffer.mapAsync(GPUMapMode.READ) + console.log(performance.now() - start) await this.#device.queue.onSubmittedWorkDone() data = new DataView(this.#cpuBuffer.getMappedRange().slice(0)) this.#cpuBuffer.unmap() diff --git a/test.html b/test.html index 10dc52f..c00e919 100644 --- a/test.html +++ b/test.html @@ -96,7 +96,8 @@ SPDX-License-Identifier: GPL-3.0-or-later console.error(err) } const end = performance.now() - const isValid = (await NanoPow.validate(work, hash, { threshold: 0 })) ? 'VALID' : 'INVALID' + // const isValid = (await NanoPow.validate(work, hash, { threshold: 0 })) ? 'VALID' : 'INVALID' + const isValid = 'Valid' times.push(end - start) const msg = `${isValid} [${work}] ${hash} (${end - start} ms)` // console.log(msg) -- 2.34.1