mirror of
https://github.com/Noratrieb/jsonformat.git
synced 2026-01-14 14:15:03 +01:00
benches
This commit is contained in:
parent
9b7260660e
commit
34b49d736c
4 changed files with 522 additions and 7 deletions
19
benches/bench.rs
Normal file
19
benches/bench.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use jsonformat::format_json;
|
||||
use std::{fs, io};
|
||||
|
||||
/// You need a json file called massive.json in your project root
|
||||
fn format_massive_json(file: &str) -> io::Result<String> {
|
||||
Ok(format_json(&file, None))
|
||||
}
|
||||
|
||||
fn criterion_benchmark(c: &mut Criterion) {
|
||||
let file = fs::read_to_string("massive.json").expect("massive.json file in project directory");
|
||||
|
||||
c.bench_function("Format massive json", |b| {
|
||||
b.iter(|| format_massive_json(&file))
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(benches, criterion_benchmark);
|
||||
criterion_main!(benches);
|
||||
Loading…
Add table
Add a link
Reference in a new issue