Skip to content

Commit

Permalink
chore: add serialize/deserialize compressed/uncompressed pubkey perf …
Browse files Browse the repository at this point in the history
…test
  • Loading branch information
twoeths committed Jul 21, 2023
1 parent 32f1383 commit 21bc7dd
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/beacon-node/test/perf/bls/bls.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {itBench} from "@dapplion/benchmark";
import bls from "@chainsafe/bls";
import type {PublicKey, SecretKey, Signature} from "@chainsafe/bls/types";
import {PointFormat, PublicKey, SecretKey, Signature} from "@chainsafe/bls/types";
import {linspace} from "../../../src/util/numpy.js";

describe("BLS ops", function () {
Expand Down Expand Up @@ -62,4 +62,18 @@ describe("BLS ops", function () {
},
});
}

for (const pointFormat of [PointFormat.compressed, PointFormat.uncompressed]) {
itBench({
id: `Serialize and deserialize public key, point format ${pointFormat}`,
beforeEach: () => getKeypair(0).publicKey,
fn: (publicKey) => {
for (let i = 0; i < 1000; i++) {
const bytes = publicKey.toBytes(pointFormat);
bls.PublicKey.fromBytes(bytes);
}
},
runsFactor: 1000,
});
}
});

0 comments on commit 21bc7dd

Please sign in to comment.