-
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 verifying key deser benchmark (#258)
- Loading branch information
Showing
4 changed files
with
45 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use rln::circuit::{to_verifying_key, RESOURCES_DIR, VK_FILENAME}; | ||
use serde_json::Value; | ||
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(); | ||
let vk = vk.contents_utf8().unwrap(); | ||
let json: Value = serde_json::from_str(vk).unwrap(); | ||
|
||
c.bench_function("circuit::to_verifying_key", |b| { | ||
b.iter(|| { | ||
let _ = to_verifying_key(&json); | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group! { | ||
name = benches; | ||
config = Criterion::default().measurement_time(std::time::Duration::from_secs(10)); | ||
targets = vk_deserialize_benchmark | ||
} | ||
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
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