From: Chris Duncan Date: Tue, 26 Nov 2024 19:16:00 +0000 (-0800) Subject: Add performance benchmarks to account derivation so it is visible in the browser. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=fb8a3fb9b445cbc1644849c7bf44f97f487a838b;p=libnemo.git Add performance benchmarks to account derivation so it is visible in the browser. --- diff --git a/src/lib/wallet.ts b/src/lib/wallet.ts index afa02be..6472738 100644 --- a/src/lib/wallet.ts +++ b/src/lib/wallet.ts @@ -418,7 +418,9 @@ export class Bip44Wallet extends Wallet { if (!Array.isArray(index)) index = [index] const data: any = [] index.forEach(i => data.push({ seed: this.seed, index: i })) + let now = performance.now() const results: [{ index: number, key: string }] = await this.#pool.work(data) + console.log(`ckd: ${-now + (now = performance.now())} ms`) const accounts = [] for (const result of results) { const { index, key } = result @@ -427,6 +429,7 @@ export class Bip44Wallet extends Wallet { } accounts.push(await Account.fromPrivateKey(key, index)) } + console.log(`accounts: ${-now + (now = performance.now())} ms`) return accounts } } @@ -573,7 +576,9 @@ export class Blake2bWallet extends Wallet { if (!Array.isArray(index)) index = [index] const data: any = [] index.forEach(i => data.push({ blake2b: blake2b.toString(), index: i, seed: this.seed })) + let now = performance.now() const results: [{ index: number, key: string }] = await this.#pool.work(data) + console.log(`ckd: ${-now + (now = performance.now())} ms`) const accounts = [] for (const result of results) { const { index, key } = result @@ -582,6 +587,7 @@ export class Blake2bWallet extends Wallet { } accounts.push(await Account.fromPrivateKey(key, index)) } + console.log(`accounts: ${-now + (now = performance.now())} ms`) return accounts } }