Merge pull request #60 from ChainSafe/dapplion/benchmark-sign

Benchmark sign()
This commit is contained in:
Cayman 2020-12-03 09:17:12 -07:00 committed by GitHub
commit a3a1831418
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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,
});
})(); })();