Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 325fca5

Browse files
committed
Fix bench
1 parent 51c59c6 commit 325fca5

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

test/benchmark/index.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { hexToBytes, utf8ToBytes } from '@noble/hashes/utils';
2-
import { mark } from '@paulmillr/jsbt/bench.js';
1+
import { hexToBytes, utf8ToBytes } from '@noble/hashes/utils.js';
2+
import bench from '@paulmillr/jsbt/bench.js';
33
import * as polka from '@polkadot/util-crypto';
4-
import { deepStrictEqual } from 'assert';
4+
import { deepStrictEqual } from 'node:assert';
55
import * as sr25519 from '../../index.ts';
66

7-
async function compare(title, runs, kinds) {
7+
async function compare(title, kinds) {
88
for (let [name, fn] of Object.entries(kinds)) {
9-
await mark(`${title} ${name}`, runs, fn);
9+
await bench(`${title} ${name}`, fn);
1010
}
1111
}
1212

@@ -32,7 +32,7 @@ async function compare(title, runs, kinds) {
3232
deepStrictEqual(pubOther, otherPairPolka.publicKey);
3333

3434
if (BENCH) {
35-
await compare('secretFromSeed', 100_000, {
35+
await compare('secretFromSeed', {
3636
wasm: () => polka.sr25519PairFromSeed(selfSeed),
3737
scure: () => sr25519.secretFromSeed(selfSeed),
3838
});
@@ -46,7 +46,7 @@ async function compare(title, runs, kinds) {
4646
deepStrictEqual(sharedPolka2, sharedNoble2);
4747

4848
if (BENCH) {
49-
await compare('getSharedSecret', 1_000, {
49+
await compare('getSharedSecret', {
5050
wasm: () => polka.sr25519Agreement(skSelf, pubOther),
5151
scure: () => sr25519.getSharedSecret(skSelf, pubOther),
5252
});
@@ -61,7 +61,7 @@ async function compare(title, runs, kinds) {
6161
deepStrictEqual(hardPolka.publicKey, sr25519.getPublicKey(hardNoble));
6262

6363
if (BENCH) {
64-
await compare('HDKD.secretHard', 50_000, {
64+
await compare('HDKD.secretHard', {
6565
wasm: () => polka.sr25519DeriveHard(pair, cc),
6666
scure: () => sr25519.HDKD.secretHard(skSelf, cc),
6767
});
@@ -75,7 +75,7 @@ async function compare(title, runs, kinds) {
7575
deepStrictEqual(softPolka.secretKey.subarray(0, 32), softNobleSecret.subarray(0, 32));
7676

7777
if (BENCH) {
78-
await compare('HDKD.secretSoft', 1_000, {
78+
await compare('HDKD.secretSoft', {
7979
wasm: () => polka.sr25519DeriveSoft(pair, cc),
8080
scure: () => sr25519.HDKD.secretSoft(skSelf, cc),
8181
});
@@ -102,11 +102,11 @@ async function compare(title, runs, kinds) {
102102
deepStrictEqual(sr25519.verify(msg, nobleSig, pair.publicKey), true);
103103

104104
if (BENCH) {
105-
await compare('sign', 1_000, {
105+
await compare('sign', {
106106
wasm: () => polka.sr25519Sign(msg, pair),
107107
scure: () => sr25519.sign(pair.secretKey, msg),
108108
});
109-
await compare('verify', 1_000, {
109+
await compare('verify', {
110110
wasm: () => polka.sr25519Verify(msg, nobleSig, pair.publicKey),
111111
scure: () => sr25519.verify(msg, nobleSig, pair.publicKey),
112112
});
@@ -121,11 +121,11 @@ async function compare(title, runs, kinds) {
121121
deepStrictEqual(sr25519.vrf.verify(msg, polkaVrfSig, pair.publicKey), true);
122122

123123
if (BENCH) {
124-
await compare('vrfSign', 1_000, {
124+
await compare('vrfSign', {
125125
wasm: () => polka.sr25519VrfSign(msg, pair),
126126
scure: () => sr25519.vrf.sign(msg, pair.secretKey),
127127
});
128-
await compare('vrfVerify', 1_000, {
128+
await compare('vrfVerify', {
129129
wasm: () => polka.sr25519VrfVerify(msg, polkaVrfSig, pair.publicKey),
130130
scure: () => sr25519.vrf.verify(msg, nobleVrfSig, pair.publicKey),
131131
});

0 commit comments

Comments
 (0)