if (this.#busy) return
this.#busy = true
// Request device and adapter
- if (navigator.gpu == null) throw new Error('WebGPU is not supported in this browser.')
try {
+ if (navigator.gpu == null) throw new Error('WebGPU is not supported in this browser.')
const adapter = await navigator.gpu.requestAdapter()
if (adapter == null) throw new Error('WebGPU adapter refused by browser.')
const device = await adapter.requestDevice()
NanoPowGpu.init()
}
- static logAverages (times: number[]): void {
+ static #logAverages (times: number[]): void {
let count = times.length, sum = 0, reciprocals = 0, logarithms = 0, truncated = 0, min = 0xffff, max = 0, rate = 0
times.sort()
for (let i = 0; i < count; i++) {
const averages = {
"Count (dispatches)": count,
"Total (ms)": sum,
- "Rate (d/s)": count / sum * 1000,
+ "Rate (d/s)": 1000 * count / (truncated || sum),
"Minimum (ms)": min,
"Maximum (ms)": max,
"Arithmetic Mean (ms)": sum / count,
this.#busy = !data.getUint32(8)
times.push(performance.now() - start)
} while (this.#busy)
- if (debug) this.logAverages(times)
+ if (debug) this.#logAverages(times)
return nonce.toString(16).padStart(16, '0')
}