console.log(`Geometric Mean: ${geometric} ms`)
}
- export async function run (size, effort, gl, debug) {
- if (gl) NanoPow = NanoPowGl
+ export async function run (size, effort, isOutputShown, isGlForced, isDebug) {
+ if (isGlForced) NanoPow = NanoPowGl
document.getElementById('status').innerHTML = `TESTING IN PROGRESS`
console.log(`%cNanoPow`, 'color:green', 'Checking validate()')
const expectFalse = await NanoPow.validate('0000000000000000', '0000000000000000000000000000000000000000000000000000000000000000')
let work = null
const start = performance.now()
try {
- work = await NanoPow.search(hash, { effort, debug })
+ work = await NanoPow.search(hash, { effort, debug: isDebug })
} catch (err) {
document.getElementById('output').innerHTML += `Error: ${err.message}<br/>`
console.error(err)
}
const end = performance.now()
+ document.getElementById('status').innerHTML = `TESTING IN PROGRESS ${i}/${size}<br/>`
const isValid = (await NanoPow.validate(work, hash)) ? 'VALID' : 'INVALID'
times.push(end - start)
const msg = `${isValid} [${work}] ${hash} (${end - start} ms)`
// console.log(msg)
- document.getElementById('output').innerHTML += `${msg}<br/>`
+ 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('go').addEventListener('click', e => {
const size = document.getElementById('size')
const effort = document.getElementById('effort')
- const gl = document.getElementById('gl')
- const debug = document.getElementById('debug')
- run(size.value, effort.value, gl.checked, debug.checked)
+ const isOutputShown = document.getElementById('isOutputShown')
+ const isGlForced = document.getElementById('isGlForced')
+ const isDebug = document.getElementById('isDebug')
+ 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>
<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="gl">Force WebGL?</label>
- <input id="gl" type="checkbox" />
- <label for="debug">Debug?</label>
- <input id="debug" type="checkbox" />
+ <label for="isOutputShown">Show output?</label>
+ <input id="isOutputShown" type="checkbox" />
+ <label for="isGlForced">Force WebGL?</label>
+ <input id="isGlForced" type="checkbox" />
+ <label for="isDebug">Debug?</label>
+ <input id="isDebug" type="checkbox" />
<button id="go">Go</button>
<h3 id="status">WAITING</h3>
<hr />