-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5e160a
commit 86573f3
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
use ark_std::rand::thread_rng; | ||
use criterion::*; | ||
use ff::Field; | ||
use goldilocks::GoldilocksExt2; | ||
use multilinear_extensions::mle::DenseMultilinearExtension; | ||
|
||
fn fix_var(c: &mut Criterion) { | ||
let mut rng = thread_rng(); | ||
|
||
const NUM_SAMPLES: usize = 10; | ||
for nv in 12..20 { | ||
let mut group = c.benchmark_group("mle"); | ||
group.sample_size(NUM_SAMPLES); | ||
|
||
for i in 0..nv { | ||
group.bench_function( | ||
BenchmarkId::new("fix_var", format!("({},{})", nv, nv - i)), | ||
|b| { | ||
b.iter_with_setup( | ||
|| { | ||
let mut v = | ||
DenseMultilinearExtension::<GoldilocksExt2>::random(nv, &mut rng); | ||
let r = GoldilocksExt2::random(&mut rng); | ||
for _ in 0..i { | ||
v.fix_variables_in_place(&[r]); | ||
} | ||
(v, r) | ||
}, | ||
|(mut v, r)| v.fix_variables_in_place(&[r]), | ||
); | ||
}, | ||
); | ||
} | ||
group.finish(); | ||
} | ||
} | ||
|
||
fn fix_var_par(c: &mut Criterion) { | ||
let mut rng = thread_rng(); | ||
|
||
const NUM_SAMPLES: usize = 10; | ||
for nv in 12..20 { | ||
let mut group = c.benchmark_group("mle"); | ||
group.sample_size(NUM_SAMPLES); | ||
|
||
for i in 0..nv { | ||
group.bench_function( | ||
BenchmarkId::new("fix_var_par", format!("({},{})", nv, nv - i)), | ||
|b| { | ||
b.iter_with_setup( | ||
|| { | ||
let mut v = | ||
DenseMultilinearExtension::<GoldilocksExt2>::random(nv, &mut rng); | ||
let r = GoldilocksExt2::random(&mut rng); | ||
for _ in 0..i { | ||
v.fix_variables_in_place(&[r]); | ||
} | ||
(v, r) | ||
}, | ||
|(mut v, r)| v.fix_variables_in_place_parallel(&[r]), | ||
); | ||
}, | ||
); | ||
} | ||
group.finish(); | ||
} | ||
} | ||
|
||
criterion_group!(benches, fix_var, fix_var_par,); | ||
criterion_main!(benches); |