}
export function average (times) {
- let sum = 0, reciprocals = 0, product = 1, count = times.length
+ let sum = 0, reciprocals = 0, product = 1, count = times.length, min = 0xffff, max = 0
for (let i = 0; i < count; i++) {
sum += times[i]
reciprocals += 1 / times[i]
product *= times[i]
+ min = Math.min(min, times[i])
+ max = Math.max(max, times[i])
}
return {
total: sum,
arithmetic: sum / count,
harmonic: count / reciprocals,
- geometric: Math.pow(product, 1 / count)
+ geometric: Math.pow(product, 1 / count),
+ min: min,
+ max: max
}
}
console.assert(failures.some(call => /.*promise should fail.*/.test(call[0])) === true, `bad promise not errored`)
console.assert(passes.some(call => /.*promise should fail.*/.test(call[0])) === false, 'bad promise logged')
- await test('async should pass', async () => { })
+ await test('async should pass', async () => {})
console.assert(failures.some(call => /.*async should pass.*/.test(call[0])) === false, 'good async errored')
console.assert(passes.some(call => /.*async should pass.*/.test(call[0])) === true, 'good async not logged')
console.assert(failures.some(call => /.*async should fail.*/.test(call[0])) === true, 'bad async not errored')
console.assert(passes.some(call => /.*async should fail.*/.test(call[0])) === false, 'bad async logged')
- await test('function should pass', () => { })
+ await test('function should pass', () => {})
console.assert(failures.some(call => /.*function should pass.*/.test(call[0])) === false, 'good function errored')
console.assert(passes.some(call => /.*function should pass.*/.test(call[0])) === true, 'good function not logged')
PASS Customized PoW: Time to calculate proof-of-work for a send block 512 times
+/media/plex/Shows/STAR_TREK_DISCOVERY_S1_D1/STAR_TREK_DISCOVERY (Season 1 Disc 1)
CHROMIUM with more accurate timings
Harmonic: 220.70399520519166 ms
Geometric: Infinity ms
Customized PoW: Time to calculate proof-of-work for a send block 512 times
+
+Total: 187827.7999998629 ms
+block.perf.js:57 Average: 366.85117187473224 ms
+block.perf.js:58 Harmonic: 223.9897252426498 ms
+block.perf.js:59 Geometric: Infinity ms
+GLOBALS.mjs:42 PASS Customized PoW: Time to calculate proof-of-work for a send block 512 times
times.push(end - start)
console.log(`${work} (${end - start} ms) ${hashes[i]}`)
}
- const { total, arithmetic, harmonic, geometric } = average(times)
+ const { total, arithmetic, harmonic, geometric, min, max } = average(times)
console.log(`Total: ${total} ms`)
console.log(`Average: ${arithmetic} ms`)
console.log(`Harmonic: ${harmonic} ms`)
console.log(`Geometric: ${geometric} ms`)
+ console.log(`Minimum: ${min} ms`)
+ console.log(`Maximum: ${max} ms`)
})
await test(`Customized PoW: Time to calculate proof-of-work for a send block ${COUNT} times`, async () => {
times.push(end - start)
console.log(`${block.work} (${end - start} ms)`)
}
- const { total, arithmetic, harmonic, geometric } = average(times)
+ const { total, arithmetic, harmonic, geometric, min, max } = average(times)
console.log(`Total: ${total} ms`)
console.log(`Average: ${arithmetic} ms`)
console.log(`Harmonic: ${harmonic} ms`)
console.log(`Geometric: ${geometric} ms`)
+ console.log(`Minimum: ${min} ms`)
+ console.log(`Maximum: ${max} ms`)
})
await skip(`Original PoW module: Time to calculate proof-of-work for a send block ${COUNT} times`, async () => {
times.push(end - start)
console.log(`${work} (${end - start} ms)`)
}
- const { total, arithmetic, harmonic, geometric } = average(times)
+ const { total, arithmetic, harmonic, geometric, min, max } = average(times)
console.log(`Total: ${total} ms`)
console.log(`Average: ${arithmetic} ms`)
console.log(`Harmonic: ${harmonic} ms`)
console.log(`Geometric: ${geometric} ms`)
+ console.log(`Minimum: ${min} ms`)
+ console.log(`Maximum: ${max} ms`)
})
})