zola/components/site/benches/render.rs

84 lines
2.4 KiB
Rust
Raw Normal View History

2017-06-22 12:37:03 +00:00
//! Benchmarking writing down on the hard drive sites of various sizes
#![feature(test)]
extern crate test;
extern crate site;
2018-04-25 08:28:23 +00:00
extern crate tempfile;
2017-06-22 12:37:03 +00:00
use std::env;
use site::Site;
2018-04-25 08:28:23 +00:00
use tempfile::tempdir;
2017-06-22 12:37:03 +00:00
#[bench]
fn bench_rendering_small_blog(b: &mut test::Bencher) {
let mut path = env::current_dir().unwrap().to_path_buf();
path.push("benches");
path.push("small-blog");
let mut site = Site::new(&path, "config.toml").unwrap();
2018-04-25 08:28:23 +00:00
let tmp_dir = tempdir().expect("create temp dir");
2017-06-22 12:37:03 +00:00
let public = &tmp_dir.path().join("public");
site.set_output_path(&public);
site.load().unwrap();
b.iter(|| site.build().unwrap());
}
#[bench]
fn bench_rendering_medium_blog(b: &mut test::Bencher) {
let mut path = env::current_dir().unwrap().to_path_buf();
path.push("benches");
path.push("medium-blog");
let mut site = Site::new(&path, "config.toml").unwrap();
2018-04-25 08:28:23 +00:00
let tmp_dir = tempdir().expect("create temp dir");
2017-06-22 12:37:03 +00:00
let public = &tmp_dir.path().join("public");
site.set_output_path(&public);
site.load().unwrap();
b.iter(|| site.build().unwrap());
}
//#[bench]
//fn bench_rendering_big_blog(b: &mut test::Bencher) {
// let mut path = env::current_dir().unwrap().to_path_buf();
// path.push("benches");
// path.push("big-blog");
// let mut site = Site::new(&path, "config.toml").unwrap();
2018-04-25 08:28:23 +00:00
// let tmp_dir = tempdir().expect("create temp dir");
2017-06-22 12:37:03 +00:00
// let public = &tmp_dir.path().join("public");
// site.set_output_path(&public);
// site.load().unwrap();
//
// b.iter(|| site.build().unwrap());
//}
#[bench]
fn bench_rendering_small_kb(b: &mut test::Bencher) {
let mut path = env::current_dir().unwrap().to_path_buf();
path.push("benches");
path.push("small-kb");
let mut site = Site::new(&path, "config.toml").unwrap();
2018-04-25 08:28:23 +00:00
let tmp_dir = tempdir().expect("create temp dir");
2017-06-22 12:37:03 +00:00
let public = &tmp_dir.path().join("public");
site.set_output_path(&public);
site.load().unwrap();
b.iter(|| site.build().unwrap());
}
#[bench]
fn bench_rendering_medium_kb(b: &mut test::Bencher) {
let mut path = env::current_dir().unwrap().to_path_buf();
path.push("benches");
path.push("medium-kb");
let mut site = Site::new(&path, "config.toml").unwrap();
2018-04-25 08:28:23 +00:00
let tmp_dir = tempdir().expect("create temp dir");
2017-06-22 12:37:03 +00:00
let public = &tmp_dir.path().join("public");
site.set_output_path(&public);
site.load().unwrap();
b.iter(|| site.build().unwrap());
}