Skip to content

Commit 1324a0d

Browse files
tests: benchmarking circuits
1 parent 4e952b9 commit 1324a0d

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"build": "rollup --config rollup.config.mjs",
2525
"test": "jest",
2626
"test:debug": "jest --silent=false",
27+
"test:benchmark": "jest --silent=false ./tests/circuit-wrapper.test.ts",
2728
"test:ci": "jest --silent=false --runInBand",
2829
"lint": "eslint --ext .ts,.tsx,.js,.jsx src/ -c .eslintrc.js",
2930
"format": "eslint --ext .ts,.tsx,.js,.jsx src/ -c .eslintrc.js --fix"
@@ -98,4 +99,4 @@
9899
"tslib": "^2.5.0",
99100
"typescript": "^4.9.5"
100101
}
101-
}
102+
}

tests/circuit-wrapper.test.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,25 @@ describe("RLN", function () {
2121
const epoch = fieldFactory()
2222
const treeDepth = DEFAULT_REGISTRY_TREE_DEPTH
2323

24-
test("should generate valid proof", async function () {
25-
const merkleProof = generateMerkleProof(rlnIdentifier, leaves, treeDepth, 0)
24+
const m0 = performance.now();
25+
const merkleProof = generateMerkleProof(rlnIdentifier, leaves, treeDepth, 0);
26+
const m1 = performance.now();
2627
const proof = await rlnProver.generateProof({
2728
rlnIdentifier,
2829
identitySecret,
2930
userMessageLimit,
3031
messageId,
3132
merkleProof,
3233
x,
33-
epoch,
34-
})
35-
expect(await rlnVerifier.verifyProof(rlnIdentifier, proof)).toBeTruthy()
34+
epoch
35+
});
36+
const m2 = performance.now();
37+
const isValid = await rlnVerifier.verifyProof(rlnIdentifier, proof);
38+
const m3 = performance.now();
39+
console.log(`Merkle proof generation: ${m1 - m0} ms`);
40+
console.log(`RLN proof generation: ${m2 - m1} ms`);
41+
console.log(`RLN proof verification: ${m3 - m2} ms`);
42+
expect(isValid).toBeTruthy();
3643
});
3744
});
3845

0 commit comments

Comments
 (0)