Fix benchmarks (#901)

* Restore #![feature(test)] and extern crate test; statements, which
were mistakenly removed as part of the Rust 2018 edition migration.

* Fix rendering benchmark's usage of RenderContext. 6 parameters were
provided when 5 were expected.
This commit is contained in:
Sam Ford 2019-12-26 07:29:17 -05:00 committed by Vincent Prouillet
parent 6b5768fd76
commit 3ef62036ef
3 changed files with 13 additions and 5 deletions

View file

@ -1,5 +1,7 @@
#![feature(test)]
extern crate test;
use std::collections::HashMap; use std::collections::HashMap;
use std::path::Path;
use config::Config; use config::Config;
use front_matter::InsertAnchor; use front_matter::InsertAnchor;
@ -85,7 +87,7 @@ fn bench_render_content_with_highlighting(b: &mut test::Bencher) {
let permalinks_ctx = HashMap::new(); let permalinks_ctx = HashMap::new();
let config = Config::default(); let config = Config::default();
let context = let context =
RenderContext::new(&tera, &config, "", &permalinks_ctx, Path::new(""), InsertAnchor::None); RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None);
b.iter(|| render_content(CONTENT, &context).unwrap()); b.iter(|| render_content(CONTENT, &context).unwrap());
} }
@ -97,7 +99,7 @@ fn bench_render_content_without_highlighting(b: &mut test::Bencher) {
let mut config = Config::default(); let mut config = Config::default();
config.highlight_code = false; config.highlight_code = false;
let context = let context =
RenderContext::new(&tera, &config, "", &permalinks_ctx, Path::new(""), InsertAnchor::None); RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None);
b.iter(|| render_content(CONTENT, &context).unwrap()); b.iter(|| render_content(CONTENT, &context).unwrap());
} }
@ -109,7 +111,7 @@ fn bench_render_content_no_shortcode(b: &mut test::Bencher) {
config.highlight_code = false; config.highlight_code = false;
let permalinks_ctx = HashMap::new(); let permalinks_ctx = HashMap::new();
let context = let context =
RenderContext::new(&tera, &config, "", &permalinks_ctx, Path::new(""), InsertAnchor::None); RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None);
b.iter(|| render_content(&content2, &context).unwrap()); b.iter(|| render_content(&content2, &context).unwrap());
} }
@ -121,7 +123,7 @@ fn bench_render_shortcodes_one_present(b: &mut test::Bencher) {
let config = Config::default(); let config = Config::default();
let permalinks_ctx = HashMap::new(); let permalinks_ctx = HashMap::new();
let context = let context =
RenderContext::new(&tera, &config, "", &permalinks_ctx, Path::new(""), InsertAnchor::None); RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None);
b.iter(|| render_shortcodes(CONTENT, &context)); b.iter(|| render_shortcodes(CONTENT, &context));
} }

View file

@ -1,4 +1,7 @@
//! Benchmarking loading/markdown rendering of generated sites of various sizes //! Benchmarking loading/markdown rendering of generated sites of various sizes
#![feature(test)]
extern crate test;
use std::env; use std::env;
use site::Site; use site::Site;

View file

@ -1,3 +1,6 @@
#![feature(test)]
extern crate test;
use std::env; use std::env;
use library::Paginator; use library::Paginator;