Skip to content

Commit c99cec7

Browse files
committed
Update program-small-big.ts to use the performance regression framework
1 parent 351f286 commit c99cec7

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/examples/zkprogram/program-small-big.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Bytes, Field, Hash, Poseidon, UInt8, ZkProgram, verify } from 'o1js';
2+
import { Performance } from '../../lib/testing/perf-regression.js';
23

34
const SmallProgram = ZkProgram({
45
name: 'small-program',
@@ -52,21 +53,24 @@ console.log('small program rows: ', csSmall.poseidonHash.rows);
5253
const csBig = await BigProgram.analyzeMethods();
5354
console.log('big program rows: ', csBig.combinedHash.rows, '\n');
5455

55-
console.time('compile small');
56+
const perfSmall = Performance.create(SmallProgram.name, csSmall);
57+
const perfBig = Performance.create(BigProgram.name, csBig);
58+
59+
perfSmall.start('compile');
5660
await SmallProgram.compile();
57-
console.timeEnd('compile small');
61+
perfSmall.end();
5862

59-
console.time('compile big');
63+
perfBig.start('compile');
6064
const { verificationKey: verificationKeyBig } = await BigProgram.compile();
61-
console.timeEnd('compile big');
65+
perfBig.end();
6266

63-
console.time('prove small');
67+
perfSmall.start('prove', 'poseidonHash');
6468
const proofSmall = await SmallProgram.poseidonHash(Field.random());
65-
console.timeEnd('prove small');
69+
perfSmall.end();
6670

67-
console.time('prove big');
71+
perfBig.start('prove', 'combinedHash');
6872
const { proof: proofBig } = await BigProgram.combinedHash(proofSmall.proof);
69-
console.timeEnd('prove big');
73+
perfBig.end();
7074

7175
console.time('verify big');
7276
await verify(proofBig, verificationKeyBig);

tests/perf-regression/perf-regression.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ STOP_AFTER=2 ./run src/examples/zkprogram/hash-chain.ts --bundle "$MODE"
2020
STOP_AFTER=4 ./run src/examples/zkprogram/gadgets.ts --bundle "$MODE"
2121
STOP_AFTER=6 ./run src/examples/zkprogram/side-loading/run.ts --bundle "$MODE"
2222
STOP_AFTER=4 ./run src/examples/zkprogram/runtime-table/run.ts --bundle "$MODE"
23+
STOP_AFTER=4 ./run src/examples/zkprogram/program-small-big.ts --bundle "$MODE"
2324

2425
# Run CS + zkApps performance regression tests
2526
./run tests/perf-regression/perf-regression.ts --bundle "$MODE"

0 commit comments

Comments
 (0)