2024-06-07 09:46:44 +00:00
|
|
|
use criterion::{criterion_group, criterion_main, Criterion};
|
2024-06-14 05:33:55 +00:00
|
|
|
use rln::circuit::{vk_from_ark_serialized, RESOURCES_DIR, VK_FILENAME};
|
2024-06-07 09:46:44 +00:00
|
|
|
use std::path::Path;
|
|
|
|
|
|
|
|
// Here we benchmark how long the deserialization of the
|
|
|
|
// verifying_key takes, only testing the json => verifying_key conversion,
|
|
|
|
// and skipping conversion from bytes => string => serde_json::Value
|
|
|
|
pub fn vk_deserialize_benchmark(c: &mut Criterion) {
|
|
|
|
let vk = RESOURCES_DIR.get_file(Path::new(VK_FILENAME)).unwrap();
|
2024-06-14 05:33:55 +00:00
|
|
|
let vk = vk.contents();
|
2024-06-07 09:46:44 +00:00
|
|
|
|
|
|
|
c.bench_function("circuit::to_verifying_key", |b| {
|
|
|
|
b.iter(|| {
|
2024-06-14 05:33:55 +00:00
|
|
|
let _ = vk_from_ark_serialized(&vk);
|
2024-06-07 09:46:44 +00:00
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
criterion_group! {
|
|
|
|
name = benches;
|
|
|
|
config = Criterion::default().measurement_time(std::time::Duration::from_secs(10));
|
|
|
|
targets = vk_deserialize_benchmark
|
|
|
|
}
|
|
|
|
criterion_main!(benches);
|