import { NanoPow } from 'nano-pow'
import { Cache, Logger, stats } from 'nano-pow/utils'
- const logger = new Logger()
-
- const glSize = (canvas => {
- const gl = canvas.getContext('webgl2')
- const MAX_VIEWPORT_DIMS = gl?.getParameter(gl.MAX_VIEWPORT_DIMS) ?? [0x1000, 0x1000]
- const size = Math.min(0x1000, ...MAX_VIEWPORT_DIMS)
- canvas.height = canvas.width = size
- return gl?.drawingBufferHeight < gl?.drawingBufferWidth ? gl?.drawingBufferHeight : gl?.drawingBufferWidth
- })(new OffscreenCanvas(0, 0))
-
- if (NanoPow) {
+ if (NanoPow && Logger) {
document.getElementById('btnStartTest').disabled = false
document.getElementById('status').innerHTML = `READY`
}
+ const logger = new Logger()
+
+ const glSize = (canvas => {
+ const gl = canvas.getContext('webgl2')
+ const MAX_VIEWPORT_DIMS = gl?.getParameter(gl.MAX_VIEWPORT_DIMS) ?? [0x1000, 0x1000]
+ const size = Math.min(0x1000, ...MAX_VIEWPORT_DIMS)
+ canvas.height = canvas.width = size
+ return gl?.drawingBufferHeight < gl?.drawingBufferWidth ? gl?.drawingBufferHeight : gl?.drawingBufferWidth
+ })(new OffscreenCanvas(0, 0))
+
function random (length = 32) {
const bytes = crypto.getRandomValues(new Uint8Array(length))
return [...bytes].map(b => b.toString(16).padStart(2, '0')).join('')
}
- function average(times, type, effort) {
+ function average (times, type, effort) {
const averages = stats(times)
const title = type === 'WebGPU'
? `NanoPow (${type}) | Effort: ${effort} | Dispatch: ${(effort << 8) << 1} | Threads: ${64 * (effort << 8) << 1}`
logger.log('%TESTING COMPLETE', 'color:orange;font-weight:bold')
}
- function startValidation(event) {
+ function startValidation (event) {
const difficulty = document.getElementById('difficulty')?.value
const work = document.getElementById('work')?.value
const hash = document.getElementById('hash')?.value
document.getElementById('hash').addEventListener('input', startValidation)
document.getElementById('api').addEventListener('input', startValidation)
- function startTest(event) {
+ function startTest (event) {
event.target.disabled = true
const api = document.getElementById('api')
const difficulty = document.getElementById('difficulty')