]> zoso.dev Git - libnemo.git/commitdiff
Add performance benchmarks to account derivation so it is visible in the browser.
authorChris Duncan <chris@zoso.dev>
Tue, 26 Nov 2024 19:16:00 +0000 (11:16 -0800)
committerChris Duncan <chris@zoso.dev>
Tue, 26 Nov 2024 19:16:00 +0000 (11:16 -0800)
src/lib/wallet.ts

index afa02be9354de79926c04b61fe23410ac75dcb35..64727384c7233358eb310b98b9e55dbd6dc71d35 100644 (file)
@@ -418,7 +418,9 @@ export class Bip44Wallet extends Wallet {
                if (!Array.isArray(index)) index = [index]\r
                const data: any = []\r
                index.forEach(i => data.push({ seed: this.seed, index: i }))\r
+               let now = performance.now()\r
                const results: [{ index: number, key: string }] = await this.#pool.work(data)\r
+               console.log(`ckd: ${-now + (now = performance.now())} ms`)\r
                const accounts = []\r
                for (const result of results) {\r
                        const { index, key } = result\r
@@ -427,6 +429,7 @@ export class Bip44Wallet extends Wallet {
                        }\r
                        accounts.push(await Account.fromPrivateKey(key, index))\r
                }\r
+               console.log(`accounts: ${-now + (now = performance.now())} ms`)\r
                return accounts\r
        }\r
 }\r
@@ -573,7 +576,9 @@ export class Blake2bWallet extends Wallet {
                if (!Array.isArray(index)) index = [index]\r
                const data: any = []\r
                index.forEach(i => data.push({ blake2b: blake2b.toString(), index: i, seed: this.seed }))\r
+               let now = performance.now()\r
                const results: [{ index: number, key: string }] = await this.#pool.work(data)\r
+               console.log(`ckd: ${-now + (now = performance.now())} ms`)\r
                const accounts = []\r
                for (const result of results) {\r
                        const { index, key } = result\r
@@ -582,6 +587,7 @@ export class Blake2bWallet extends Wallet {
                        }\r
                        accounts.push(await Account.fromPrivateKey(key, index))\r
                }\r
+               console.log(`accounts: ${-now + (now = performance.now())} ms`)\r
                return accounts\r
        }\r
 }\r