console.log(`Geometric Mean: ${geometric} ms`)
}
- console.log(`%cNanoWebGpu`, 'color:green', 'Testing validation function')
- const expectFalse = await NanoPowGpu.validate('0000000000000000', '0000000000000000000000000000000000000000000000000000000000000000')
+ console.log(`%cNanoPow`, 'color:green', 'Testing validation function')
+ const expectFalse = await NanoPow.validate('0000000000000000', '0000000000000000000000000000000000000000000000000000000000000000')
console.log(`validate() output for bad nonce is ${expectFalse === false ? 'correct' : 'incorrect'}`)
- const expectTrue = await NanoPowGpu.validate('47c83266398728cf', '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D')
+ const expectTrue = await NanoPow.validate('47c83266398728cf', '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D')
console.log(`validate() output for good nonce is ${expectTrue === true ? 'correct' : 'incorrect'}`)
+ console.log(`%cNanoPow `, 'color:green', `Calculate proof-of-work for ${COUNT} unique send block hashes`)
+ times = []
+ document.getElementById('output').innerHTML += `Now testing: NanoPow<br/>`
+ for (let i = 0; i < COUNT; i++) {
+ const hash = random()
+ let work = null
+ let isValid = null
+ const start = performance.now()
+ try {
+ work = await NanoPow.search(hash)
+ isValid = (await NanoPow.validate(work, hash)) ? 'VALID' : 'INVALID'
+ } catch (err) {
+ document.getElementById('output').innerHTML += `Error: ${err.message}<br/>`
+ console.error(err)
+ }
+ const end = performance.now()
+ times.push(end - start)
+ const msg = `${isValid} [${work}] ${hash} (${end - start} ms)`
+ console.log(msg)
+ document.getElementById('output').innerHTML += `${msg}<br/>`
+ }
+ document.getElementById('output').innerHTML += `-----<br/>`
+ document.getElementById('summary').innerHTML += `NanoPow<br/>${JSON.stringify(average(times), null, '\t')}<br/>`
+ print(times)
+
console.log(`%cNanoPowGpu `, 'color:green', `Calculate proof-of-work for ${COUNT} unique send block hashes`)
times = []
document.getElementById('output').innerHTML += `Now testing: NanoPowGpu<br/>`