benchmark as jacobian

This commit is contained in:
dapplion 2020-11-14 22:25:22 +00:00
parent 928b86a9fb
commit f29898d9dc
1 changed files with 20 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import crypto from "crypto"; import crypto from "crypto";
import * as blst from "@chainsafe/blst-ts"; import * as blst from "@chainsafe/blst-ts";
import {blst as blstBindings} from "@chainsafe/blst-ts/dist/bindings";
import * as herumi from "../../src"; import * as herumi from "../../src";
import {runBenchmark} from "./runner"; import {runBenchmark} from "./runner";
@ -116,6 +117,25 @@ import {runBenchmark} from "./runner";
}, },
}); });
runBenchmark<blst.AggregatePublicKey[], void>({
id: `BLST aggregatePubkeys as jacobian (${aggCount})`,
prepareTest: () => {
return {
input: range(aggCount).map(() => {
const pk = blst.SecretKey.fromKeygen(crypto.randomBytes(32)).toPublicKey();
return blst.AggregatePublicKey.fromPublicKey(pk);
}),
};
},
testRunner: (pks) => {
const p1Arr = pks.map((pk) => pk.value);
p1Arr.reduce((agg, pk) => {
return blstBindings.P1.add(agg, pk);
});
},
});
runBenchmark<herumi.PublicKey[], void>({ runBenchmark<herumi.PublicKey[], void>({
id: `HERUMI aggregatePubkeys (${aggCount})`, id: `HERUMI aggregatePubkeys (${aggCount})`,