[[bench]]
name = "dir"
harness = false
+
+[[bench]]
+name = "file"
+harness = false
+
+[[bench]]
+name = "pandoc"
+harness = false
criterion_group! {
name = benches;
- config = Criterion::default().sample_size(10);
+ config = Criterion::default().sample_size(10).measurement_time(core::time::Duration::from_secs(135));
targets = build_dir
}
--- /dev/null
+use criterion::{black_box, criterion_group, criterion_main, Criterion};
+
+pub fn build_file(c: &mut Criterion) {
+ let dir = std::path::PathBuf::from("files/bench_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");
+
+ let mut file: metaforge::MetaFile = metaforge::MetaFile::new(&opts);
+ let path = opts.source.join("bench.meta");
+
+ c.bench_function("build file", |b| {
+ b.iter(|| {
+ file = metaforge::MetaFile::build(black_box(path.clone()), black_box(&opts)).unwrap();
+ file.construct().unwrap();
+ })
+ });
+}
+
+criterion_group! {
+ name = benches;
+ config = Criterion::default().sample_size(10);
+ targets = build_file
+}
+
+criterion_main!(benches);
--- /dev/null
+use criterion::{black_box, criterion_group, criterion_main, Criterion};
+
+pub fn no_pandoc(c: &mut Criterion) {
+ let dir = std::path::PathBuf::from("files/bench_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.no_pandoc = true;
+
+ let mut file: metaforge::MetaFile = metaforge::MetaFile::new(&opts);
+ let path = opts.source.join("bench.meta");
+
+ c.bench_function("no pandoc", |b| {
+ b.iter(|| {
+ file = metaforge::MetaFile::build(black_box(path.clone()), black_box(&opts)).unwrap();
+ file.construct().unwrap();
+ })
+ });
+}
+
+criterion_group! {
+ name = benches;
+ config = Criterion::default().sample_size(100);
+ targets = no_pandoc
+}
+
+criterion_main!(benches);
--- /dev/null
+use criterion::{black_box, criterion_group, criterion_main, Criterion};
+
+pub fn build_dir(c: &mut Criterion) {
+ let dir = std::path::PathBuf::from("files/bench_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;
+
+ c.bench_function("build dir", |b| {
+ if opts.build.exists() {
+ std::fs::remove_dir_all(&opts.build).expect("clean build dir");
+ }
+
+ std::fs::create_dir(&opts.build).expect("create build dir");
+ b.iter(|| metaforge::build_site(black_box(&opts)).unwrap())
+ });
+}
+
+criterion_group! {
+ name = benches;
+ config = Criterion::default().sample_size(10).measurement_time(core::time::Duration::from_secs(140));
+ targets = build_dir
+}
+
+criterion_main!(benches);