From 3ef62036ef7cd76cf1485cdf7d60fcb893e00fc5 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Thu, 26 Dec 2019 07:29:17 -0500 Subject: [PATCH] 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. --- components/rendering/benches/all.rs | 12 +++++++----- components/site/benches/load.rs | 3 +++ components/site/benches/site.rs | 3 +++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/components/rendering/benches/all.rs b/components/rendering/benches/all.rs index 689ffd3..4045170 100644 --- a/components/rendering/benches/all.rs +++ b/components/rendering/benches/all.rs @@ -1,5 +1,7 @@ +#![feature(test)] +extern crate test; + use std::collections::HashMap; -use std::path::Path; use config::Config; use front_matter::InsertAnchor; @@ -85,7 +87,7 @@ fn bench_render_content_with_highlighting(b: &mut test::Bencher) { let permalinks_ctx = HashMap::new(); let config = Config::default(); 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()); } @@ -97,7 +99,7 @@ fn bench_render_content_without_highlighting(b: &mut test::Bencher) { let mut config = Config::default(); config.highlight_code = false; 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()); } @@ -109,7 +111,7 @@ fn bench_render_content_no_shortcode(b: &mut test::Bencher) { config.highlight_code = false; let permalinks_ctx = HashMap::new(); 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()); } @@ -121,7 +123,7 @@ fn bench_render_shortcodes_one_present(b: &mut test::Bencher) { let config = Config::default(); let permalinks_ctx = HashMap::new(); 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)); } diff --git a/components/site/benches/load.rs b/components/site/benches/load.rs index af8b40d..3cee15f 100644 --- a/components/site/benches/load.rs +++ b/components/site/benches/load.rs @@ -1,4 +1,7 @@ //! Benchmarking loading/markdown rendering of generated sites of various sizes +#![feature(test)] +extern crate test; + use std::env; use site::Site; diff --git a/components/site/benches/site.rs b/components/site/benches/site.rs index 2fbd930..3436f88 100644 --- a/components/site/benches/site.rs +++ b/components/site/benches/site.rs @@ -1,3 +1,6 @@ +#![feature(test)] +extern crate test; + use std::env; use library::Paginator;