-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proof-Setup: Make benchmarks run over all circuits
Probably the more useful benchmarks to run
- Loading branch information
1 parent
f5425f7
commit 1d12603
Showing
6 changed files
with
101 additions
and
117 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod all; | ||
mod parallel_utils; | ||
pub mod single; |
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,36 @@ | ||
pub fn transform<A, B, const N: usize>(data: [A; N], f: impl Fn(A) -> B) -> [B; N] { | ||
match data.into_iter().map(f).collect::<Vec<B>>().try_into() { | ||
Ok(x) => x, | ||
_ => panic!("The size of the iterator should not have changed"), | ||
} | ||
} | ||
|
||
#[cfg(not(feature = "parallel"))] | ||
pub fn transform_parallel<A, B, const N: usize>(data: [A; N], f: impl Fn(A) -> B) -> [B; N] { | ||
transform(data, f) | ||
} | ||
|
||
#[cfg(feature = "parallel")] | ||
pub fn transform_parallel<A: Send, B: Sync + Send, const N: usize>( | ||
data: [A; N], | ||
f: impl Fn(A) -> B + Sync + Send, | ||
) -> [B; N] { | ||
use rayon::prelude::*; | ||
let out: Vec<B> = data.into_par_iter().map(f).collect(); | ||
// Note: we do it this way because we don't have a Debug implementation for B | ||
match out.try_into() { | ||
Ok(x) => x, | ||
_ => panic!("The size of the iterator should not have changed"), | ||
} | ||
} | ||
|
||
pub fn flatten_results<A, E, const N: usize>(data: [Result<A, E>; N]) -> Result<[A; N], E> { | ||
let mut buf = Vec::with_capacity(N); | ||
for x in data { | ||
buf.push(x?); | ||
} | ||
match buf.try_into() { | ||
Ok(x) => Ok(x), | ||
_ => panic!("The size of the iterator should not have changed"), | ||
} | ||
} |
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