This commit is contained in:
nora 2021-07-17 23:06:40 +02:00
parent 9b7260660e
commit 34b49d736c
4 changed files with 522 additions and 7 deletions

19
benches/bench.rs Normal file
View 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);