Benchmark sign()

This commit is contained in:
dapplion 2020-12-03 09:38:13 +00:00
parent e8d81fef96
commit 9b6369c07a
2 changed files with 35 additions and 1 deletions

View File

@ -1,6 +1,6 @@
import {runBenchmark} from "./runner"; import {runBenchmark} from "./runner";
import {runForAllImplementations} from "../test/switch"; import {runForAllImplementations} from "../test/switch";
import {PublicKey, Signature} from "../src/interface"; import {PublicKey, Signature, SecretKey} from "../src/interface";
import {range, randomMessage} from "../test/util"; import {range, randomMessage} from "../test/util";
import {aggCount, runs} from "./params"; import {aggCount, runs} from "./params";
@ -120,5 +120,22 @@ import {aggCount, runs} from "./params";
}, },
runs, runs,
}); });
// Sign
await runBenchmark<{sk: SecretKey; msg: Uint8Array}, void>({
id: `${implementation} sign`,
prepareTest: () => ({
input: {
sk: bls.SecretKey.fromKeygen(),
msg: randomMessage(),
},
}),
testRunner: ({sk, msg}) => {
sk.sign(msg);
},
runs,
});
}); });
})(); })();

View File

@ -104,4 +104,21 @@ import {aggCount, runsNoble} from "./params";
}, },
runs: runsNoble, runs: runsNoble,
}); });
// Sign
await runBenchmark<{sk: Uint8Array; msg: Uint8Array}, void>({
id: `noble sign`,
prepareTest: async () => ({
input: {
sk: generateRandomSecretKey(),
msg: randomMessage(),
},
}),
testRunner: async ({sk, msg}) => {
await noble.sign(msg, sk);
},
runs: runsNoble,
});
})(); })();