11use criterion:: { criterion_group, criterion_main, BenchmarkId , Criterion } ;
2- use expander_rs:: utils:: { KECCAK_M31_CIRCUIT , POSEIDON_CIRCUIT } ;
2+ use expander_rs:: utils:: {
3+ KECCAK_BN254_CIRCUIT , KECCAK_BN254_WITNESS , KECCAK_M31_CIRCUIT , KECCAK_M31_WITNESS ,
4+ POSEIDON_BN254_CIRCUIT , POSEIDON_M31_CIRCUIT ,
5+ } ;
36use expander_rs:: {
47 BN254ConfigSha2 , Circuit , Config , GKRConfig , GKRScheme , M31ExtConfigSha2 , MPIConfig , Prover ,
58} ;
@@ -11,18 +14,33 @@ fn prover_run<C: GKRConfig>(config: &Config<C>, circuit: &mut Circuit<C>) {
1114 prover. prove ( circuit) ;
1215}
1316
14- fn benchmark_setup < C : GKRConfig > ( scheme : GKRScheme , circuit_file : & str ) -> ( Config < C > , Circuit < C > ) {
17+ fn benchmark_setup < C : GKRConfig > (
18+ scheme : GKRScheme ,
19+ circuit_file : & str ,
20+ witness_file : Option < & str > ,
21+ ) -> ( Config < C > , Circuit < C > ) {
1522 let config = Config :: < C > :: new ( scheme, MPIConfig :: new ( ) ) ;
1623 let mut circuit = Circuit :: < C > :: load_circuit ( circuit_file) ;
17- circuit. set_random_input_for_test ( ) ;
24+ if witness_file. is_some ( ) {
25+ circuit. load_witness_file ( witness_file. unwrap ( ) ) ;
26+ } else {
27+ circuit. set_random_input_for_test ( ) ;
28+ }
1829 ( config, circuit)
1930}
2031
2132fn criterion_gkr_keccak ( c : & mut Criterion ) {
22- let ( m31_config, mut m31_circuit) =
23- benchmark_setup :: < M31ExtConfigSha2 > ( GKRScheme :: Vanilla , KECCAK_M31_CIRCUIT ) ;
24- let ( bn254_config, mut bn254_circuit) =
25- benchmark_setup :: < BN254ConfigSha2 > ( GKRScheme :: Vanilla , KECCAK_M31_CIRCUIT ) ;
33+ let ( m31_config, mut m31_circuit) = benchmark_setup :: < M31ExtConfigSha2 > (
34+ GKRScheme :: Vanilla ,
35+ KECCAK_M31_CIRCUIT ,
36+ Some ( KECCAK_M31_WITNESS ) ,
37+ ) ;
38+ let ( bn254_config, mut bn254_circuit) = benchmark_setup :: < BN254ConfigSha2 > (
39+ GKRScheme :: Vanilla ,
40+ KECCAK_BN254_CIRCUIT ,
41+ Some ( KECCAK_BN254_WITNESS ) ,
42+ ) ;
43+
2644 let num_keccak_m31 = 2 * M31ExtConfigSha2 :: get_field_pack_size ( ) ;
2745 let num_keccak_bn254 = 2 * BN254ConfigSha2 :: get_field_pack_size ( ) ;
2846
@@ -66,9 +84,9 @@ fn criterion_gkr_keccak(c: &mut Criterion) {
6684
6785fn criterion_gkr_poseidon ( c : & mut Criterion ) {
6886 let ( m31_config, mut m31_circuit) =
69- benchmark_setup :: < M31ExtConfigSha2 > ( GKRScheme :: GkrSquare , POSEIDON_CIRCUIT ) ;
87+ benchmark_setup :: < M31ExtConfigSha2 > ( GKRScheme :: GkrSquare , POSEIDON_M31_CIRCUIT , None ) ;
7088 let ( bn254_config, mut bn254_circuit) =
71- benchmark_setup :: < BN254ConfigSha2 > ( GKRScheme :: GkrSquare , POSEIDON_CIRCUIT ) ;
89+ benchmark_setup :: < BN254ConfigSha2 > ( GKRScheme :: GkrSquare , POSEIDON_BN254_CIRCUIT , None ) ;
7290
7391 let mut group = c. benchmark_group ( "single thread proving poseidon by GKR^2" ) ;
7492 let num_poseidon_m31 = 120 * M31ExtConfigSha2 :: get_field_pack_size ( ) ;
0 commit comments