-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(rln): add uncompressed key and benches (#269)
* chore(rln): add uncompressed key and benches * chore(rln): refactor * chore(rln): update to uncompressed arkzkey
- Loading branch information
1 parent
49e2517
commit b9d2703
Showing
6 changed files
with
167 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use rln::circuit::{ | ||
read_arkzkey_from_bytes_compressed, read_arkzkey_from_bytes_uncompressed, ARKZKEY_BYTES, | ||
ARKZKEY_BYTES_UNCOMPR, | ||
}; | ||
|
||
pub fn uncompressed_bench(c: &mut Criterion) { | ||
let arkzkey = ARKZKEY_BYTES_UNCOMPR.to_vec(); | ||
let size = arkzkey.len() as f32; | ||
println!( | ||
"Size of uncompressed arkzkey: {:.2?} MB", | ||
size / 1024.0 / 1024.0 | ||
); | ||
|
||
c.bench_function("arkzkey::arkzkey_from_raw_uncompressed", |b| { | ||
b.iter(|| { | ||
let r = read_arkzkey_from_bytes_uncompressed(&arkzkey); | ||
assert_eq!(r.is_ok(), true); | ||
}) | ||
}); | ||
} | ||
pub fn compressed_bench(c: &mut Criterion) { | ||
let arkzkey = ARKZKEY_BYTES.to_vec(); | ||
let size = arkzkey.len() as f32; | ||
println!( | ||
"Size of compressed arkzkey: {:.2?} MB", | ||
size / 1024.0 / 1024.0 | ||
); | ||
|
||
c.bench_function("arkzkey::arkzkey_from_raw_compressed", |b| { | ||
b.iter(|| { | ||
let r = read_arkzkey_from_bytes_compressed(&arkzkey); | ||
assert_eq!(r.is_ok(), true); | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group! { | ||
name = benches; | ||
config = Criterion::default().measurement_time(std::time::Duration::from_secs(250)); | ||
targets = uncompressed_bench, compressed_bench | ||
} | ||
criterion_main!(benches); |
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,21 +1,24 @@ | ||
use ark_circom::read_zkey; | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use rln::circuit::{zkey_from_raw, ZKEY_BYTES}; | ||
use std::io::Cursor; | ||
|
||
// Depending on the key type (enabled by the `--features arkzkey` flag) | ||
// the upload speed from the `rln_final.zkey` or `rln_final.arkzkey` file is calculated | ||
pub fn key_load_benchmark(c: &mut Criterion) { | ||
let zkey = ZKEY_BYTES.to_vec(); | ||
pub fn zkey_load_benchmark(c: &mut Criterion) { | ||
let zkey = rln::circuit::ZKEY_BYTES.to_vec(); | ||
let size = zkey.len() as f32; | ||
println!("Size of zkey: {:.2?} MB", size / 1024.0 / 1024.0); | ||
|
||
c.bench_function("zkey::zkey_from_raw", |b| { | ||
b.iter(|| { | ||
let _ = zkey_from_raw(&zkey); | ||
let mut reader = Cursor::new(zkey.clone()); | ||
let r = read_zkey(&mut reader); | ||
assert_eq!(r.is_ok(), true); | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group! { | ||
name = benches; | ||
config = Criterion::default().measurement_time(std::time::Duration::from_secs(250)); | ||
targets = key_load_benchmark | ||
targets = zkey_load_benchmark | ||
} | ||
criterion_main!(benches); |
Binary file not shown.
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