From 0fa95e1f7e98713c8b573c5de1501da44e37b8d1 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sat, 7 Dec 2024 22:49:14 -0800 Subject: [PATCH] Rename and add account performance tests. --- perf/account.perf.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/perf/account.perf.js b/perf/account.perf.js index 4f97b9c..612414e 100644 --- a/perf/account.perf.js +++ b/perf/account.perf.js @@ -7,7 +7,7 @@ import { assert, skip, test } from '#GLOBALS.mjs' import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js' import { Bip44Wallet, Blake2bWallet } from '#dist/main.js' -await test('BIP-44 ckd performance test', async () => { +await test('total time to create 0x8000 BIP-44 accounts', async () => { const wallet = await Bip44Wallet.create(NANO_TEST_VECTORS.PASSWORD) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) let now = performance.now() @@ -16,7 +16,18 @@ await test('BIP-44 ckd performance test', async () => { assert.equals(accounts.length, 0x8000) }) -await test('BLAKE2b ckd performance test', async () => { +await test('average time to create 1 BIP-44 account 0x80 times', async () => { + const wallet = await Bip44Wallet.create(NANO_TEST_VECTORS.PASSWORD) + await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) + let now = performance.now() + for (let i = 0; i < 0x80; i++) { + await wallet.accounts(i) + } + const avg = (performance.now() - now) / 0x80 + console.log(`${avg} ms`) +}) + +await test('create 0x8000 BLAKE2b accounts', async () => { const wallet = await Blake2bWallet.create(NANO_TEST_VECTORS.PASSWORD) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) let now = performance.now() @@ -24,3 +35,15 @@ await test('BLAKE2b ckd performance test', async () => { console.log(`${performance.now() - now} ms`) assert.equals(accounts.length, 0x8000) }) + + +await test('average time to create 1 BLAKE2b account 0x80 times', async () => { + const wallet = await Blake2bWallet.create(NANO_TEST_VECTORS.PASSWORD) + await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) + let now = performance.now() + for (let i = 0; i < 0x80; i++) { + await wallet.accounts(i) + } + const avg = (performance.now() - now) / 0x80 + console.log(`${avg} ms`) +}) -- 2.34.1