Browse Source

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.
index-subcmd
Sam Ford Vincent Prouillet 4 years ago
parent
commit
3ef62036ef
3 changed files with 13 additions and 5 deletions
  1. +7
    -5
      components/rendering/benches/all.rs
  2. +3
    -0
      components/site/benches/load.rs
  3. +3
    -0
      components/site/benches/site.rs

+ 7
- 5
components/rendering/benches/all.rs 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));
} }

+ 3
- 0
components/site/benches/load.rs 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;


+ 3
- 0
components/site/benches/site.rs View File

@@ -1,3 +1,6 @@
#![feature(test)]
extern crate test;

use std::env; use std::env;


use library::Paginator; use library::Paginator;


Loading…
Cancel
Save