await suite('Block performance', async () => {
const COUNT = 0x1
- await test(`Original PoW module: Time to calculate proof-of-work for a send block ${COUNT} times`, async () => {
+ await test(`Customized PoW: Time to calculate proof-of-work for a send block ${COUNT} times`, async () => {
const times = []
+ const block = new SendBlock(
+ NANO_TEST_VECTORS.SEND_BLOCK.account,
+ NANO_TEST_VECTORS.SEND_BLOCK.balance,
+ NANO_TEST_VECTORS.SEND_BLOCK.link,
+ '0',
+ NANO_TEST_VECTORS.SEND_BLOCK.representative,
+ NANO_TEST_VECTORS.SEND_BLOCK.previous
+ )
for (let i = 0; i < COUNT; i++) {
const start = performance.now()
- const work = await new Promise(resolve => {
- //@ts-expect-error
- window.NanoWebglPow(NANO_TEST_VECTORS.SEND_BLOCK.previous, resolve, undefined, '0xFFFFFFF8')
- })
+ await block.pow()
const end = performance.now()
times.push(end - start)
- console.log(`${work} (${end - start} ms)`)
+ console.log(`${block.work} (${end - start} ms)`)
}
const { total, arithmetic, harmonic, geometric } = average(times)
console.log(`Total: ${total} ms`)
console.log(`Geometric: ${geometric} ms`)
})
- await test(`Customized PoW: Time to calculate proof-of-work for a send block ${COUNT} times`, async () => {
+ await test(`Original PoW module: Time to calculate proof-of-work for a send block ${COUNT} times`, async () => {
const times = []
- const block = new SendBlock(
- NANO_TEST_VECTORS.SEND_BLOCK.account,
- NANO_TEST_VECTORS.SEND_BLOCK.balance,
- NANO_TEST_VECTORS.SEND_BLOCK.link,
- '0',
- NANO_TEST_VECTORS.SEND_BLOCK.representative,
- NANO_TEST_VECTORS.SEND_BLOCK.previous
- )
for (let i = 0; i < COUNT; i++) {
const start = performance.now()
- await block.pow()
+ const work = await new Promise(resolve => {
+ //@ts-expect-error
+ window.NanoWebglPow(NANO_TEST_VECTORS.SEND_BLOCK.previous, resolve, undefined, '0xFFFFFFF8')
+ })
const end = performance.now()
times.push(end - start)
- console.log(`${block.work} (${end - start} ms)`)
+ console.log(`${work} (${end - start} ms)`)
}
const { total, arithmetic, harmonic, geometric } = average(times)
console.log(`Total: ${total} ms`)