Add one bench for rendering html of page

This commit is contained in:
Vincent Prouillet 2017-07-04 19:55:28 +09:00
parent 2227b8646c
commit 3022598649

View file

@ -133,3 +133,16 @@ fn bench_populate_previous_and_next_pages(b: &mut test::Bencher) {
let (sorted_pages, _) = sort_pages(pages, SortBy::Order); let (sorted_pages, _) = sort_pages(pages, SortBy::Order);
b.iter(|| populate_previous_and_next_pages(sorted_pages.clone())); b.iter(|| populate_previous_and_next_pages(sorted_pages.clone()));
} }
#[bench]
fn bench_page_render_html(b: &mut test::Bencher) {
let pages = create_pages(10, SortBy::Order);
let (mut sorted_pages, _) = sort_pages(pages, SortBy::Order);
sorted_pages = populate_previous_and_next_pages(sorted_pages.clone());
let config = Config::default();
let mut tera = Tera::default();
tera.add_raw_template("page.html", "{{ page.content }}").unwrap();
let page = &sorted_pages[5];
b.iter(|| page.render_html(&tera, &config).unwrap());
}