From 76f0a1119141d9f4de2615c2ce983c457249425a Mon Sep 17 00:00:00 2001 From: Huck Boles Date: Mon, 15 May 2023 21:07:32 -0500 Subject: [PATCH] only dir benchmark --- Cargo.toml | 4 ---- benches/file.rs | 34 ---------------------------------- 2 files changed, 38 deletions(-) delete mode 100644 benches/file.rs diff --git a/Cargo.toml b/Cargo.toml index ccaf54e..4968c4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,10 +13,6 @@ pest_derive = "2" [dev-dependencies] criterion = "0.4" -[[bench]] -name = "file" -harness = false - [[bench]] name = "dir" harness = false diff --git a/benches/file.rs b/benches/file.rs deleted file mode 100644 index e333ccd..0000000 --- a/benches/file.rs +++ /dev/null @@ -1,34 +0,0 @@ -use criterion::{black_box, criterion_group, criterion_main, Criterion}; - -pub fn build_file_benchmark(c: &mut Criterion) { - let dir = std::path::PathBuf::from("files/benchmark_site") - .canonicalize() - .unwrap(); - - let mut opts = metaforge::Options::new(); - opts.root = dir.clone(); - opts.source = dir.join("source"); - opts.build = dir.join("build"); - opts.pattern = dir.join("pattern"); - opts.clean = true; - - let source = opts.source.join("benchmark.meta"); - - c.bench_function("build file", |b| { - b.iter(|| { - let string = std::fs::read_to_string(black_box(&source)).expect("read file"); - let mut file = metaforge::parse_file(string, black_box(&opts)).expect("parse file"); - file.path = black_box(source.clone()); - let string = metaforge::build_metafile(&file).expect("build file"); - std::fs::write(file.dest().expect("find dest"), string).expect("write file"); - }) - }); -} - -criterion_group! { - name = benches; - config = Criterion::default().sample_size(10); - targets = build_file_benchmark -} - -criterion_main!(benches); -- 2.45.2