? 0xfffffff8
: options.threshold
const effort = (typeof options?.effort !== 'number' || options.effort < 0x1 || options.effort > 0x10)
- ? 0x8
- : options.effort
+ ? 0x800
+ : options.effort * 0x100
const debug = !!(options?.debug)
// Ensure WebGPU is initialized before calculating
start = performance.now()
const random = Math.floor(Math.random() * 0xffffffff)
const seed = (BigInt(random) << 32n) | BigInt(random)
- const data = await this.#dispatch(this.#searchPipeline, seed, hash, threshold, effort * 0x100)
+ const data = await this.#dispatch(this.#searchPipeline, seed, hash, threshold, effort)
nonce = data.getBigUint64(0, true)
this.#busy = !data.getUint32(8)
times.push(performance.now() - start)
} while (this.#busy)
- if (debug) this.#logAverages(times)
+ if (debug) {
+ console.log(`%cNanoPow (WebGPU) | Dispatch: ${effort ** 2} | Threads: ${8 * 8 * (effort ** 2)}`)
+ this.#logAverages(times)
+ }
return nonce.toString(16).padStart(16, '0')
}
console.log(`%cNanoPow (${type})`, 'color:green', `Calculate proof-of-work for ${size} unique send block hashes`)
const times = []
- document.getElementById('output').innerHTML += `Now testing: NanoPow (${type}) | Dispatch: ${(effort * 0x100) ** 2} | Threads/Dispatch: ${8 * 8 * ((effort * 0x100) ** 2)}<br/>`
for (let i = 0; i < size; i++) {
document.getElementById('status').innerHTML = `TESTING IN PROGRESS ${i}/${size}<br/>`
const hash = random()
// console.log(msg)
if (isOutputShown) document.getElementById('output').innerHTML += `${msg}<br/>`
}
- document.getElementById('output').innerHTML += `-----<br/>`
- document.getElementById('summary').innerHTML += `NanoPow (${type})<br/>${JSON.stringify(average(times), null, '\t')}<br/>`
+ document.getElementById('output').innerHTML += `<hr/>`
+ document.getElementById('summary').innerHTML += `${JSON.stringify(average(times), null, '\t')}<br/>`
print(times)
document.getElementById('status').innerHTML = `TESTING COMPLETE<br/>`
console.log('%cTESTING COMPLETE', 'color:orange;font-weight:bold')
run(+size.value, +effort.value, isOutputShown.checked, isGlForced.checked, isDebug.checked)
})
</script>
- <style>body{background:black;color:white;}a{color:darkcyan;}input[type=number]{width:5em;}</style>
+ <style>body{background:black;color:white;}a{color:darkcyan;}input[type=number]{width:5em;}span{margin:0.5em;}</style>
</head>
<body>
<input id="size" type="number" value="64" />
<label for="effort">Effort (1-16)</label>
<input id="effort" type="number" value="8" min="1" max="16" />
- <label for="isOutputShown">Show output?</label>
- <input id="isOutputShown" type="checkbox" checked />
- <label for="isGlForced">Force WebGL?</label>
- <input id="isGlForced" type="checkbox" />
- <label for="isDebug">Debug?</label>
- <input id="isDebug" type="checkbox" />
+ <span>
+ <label for="isOutputShown">Show output?</label>
+ <input id="isOutputShown" type="checkbox" checked />
+ </span>
+ <span>
+ <label for="isGlForced">Force WebGL?</label>
+ <input id="isGlForced" type="checkbox" />
+ </span>
+ <span>
+ <label for="isDebug">Debug?</label>
+ <input id="isDebug" type="checkbox" />
+ </span>
<button id="go">Go</button>
<h3 id="status">WAITING</h3>
<hr />