|
@@ -7,6 +7,7 @@ extern crate config; |
|
|
extern crate front_matter; |
|
|
extern crate front_matter; |
|
|
|
|
|
|
|
|
use std::collections::HashMap; |
|
|
use std::collections::HashMap; |
|
|
|
|
|
use std::path::Path; |
|
|
|
|
|
|
|
|
use tera::Tera; |
|
|
use tera::Tera; |
|
|
use rendering::{RenderContext, render_content, render_shortcodes}; |
|
|
use rendering::{RenderContext, render_content, render_shortcodes}; |
|
@@ -91,7 +92,7 @@ fn bench_render_content_with_highlighting(b: &mut test::Bencher) { |
|
|
tera.add_raw_template("shortcodes/youtube.html", "{{id}}").unwrap(); |
|
|
tera.add_raw_template("shortcodes/youtube.html", "{{id}}").unwrap(); |
|
|
let permalinks_ctx = HashMap::new(); |
|
|
let permalinks_ctx = HashMap::new(); |
|
|
let config = Config::default(); |
|
|
let config = Config::default(); |
|
|
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
|
|
|
|
|
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, Path::new(""), InsertAnchor::None); |
|
|
b.iter(|| render_content(CONTENT, &context).unwrap()); |
|
|
b.iter(|| render_content(CONTENT, &context).unwrap()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -102,7 +103,7 @@ fn bench_render_content_without_highlighting(b: &mut test::Bencher) { |
|
|
let permalinks_ctx = HashMap::new(); |
|
|
let permalinks_ctx = HashMap::new(); |
|
|
let mut config = Config::default(); |
|
|
let mut config = Config::default(); |
|
|
config.highlight_code = false; |
|
|
config.highlight_code = false; |
|
|
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
|
|
|
|
|
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, Path::new(""), InsertAnchor::None); |
|
|
b.iter(|| render_content(CONTENT, &context).unwrap()); |
|
|
b.iter(|| render_content(CONTENT, &context).unwrap()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -113,7 +114,7 @@ fn bench_render_content_no_shortcode(b: &mut test::Bencher) { |
|
|
let mut config = Config::default(); |
|
|
let mut config = Config::default(); |
|
|
config.highlight_code = false; |
|
|
config.highlight_code = false; |
|
|
let permalinks_ctx = HashMap::new(); |
|
|
let permalinks_ctx = HashMap::new(); |
|
|
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
|
|
|
|
|
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, Path::new(""), InsertAnchor::None); |
|
|
|
|
|
|
|
|
b.iter(|| render_content(&content2, &context).unwrap()); |
|
|
b.iter(|| render_content(&content2, &context).unwrap()); |
|
|
} |
|
|
} |
|
@@ -124,7 +125,7 @@ fn bench_render_shortcodes_one_present(b: &mut test::Bencher) { |
|
|
tera.add_raw_template("shortcodes/youtube.html", "{{id}}").unwrap(); |
|
|
tera.add_raw_template("shortcodes/youtube.html", "{{id}}").unwrap(); |
|
|
let config = Config::default(); |
|
|
let config = Config::default(); |
|
|
let permalinks_ctx = HashMap::new(); |
|
|
let permalinks_ctx = HashMap::new(); |
|
|
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
|
|
|
|
|
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, Path::new(""), InsertAnchor::None); |
|
|
|
|
|
|
|
|
b.iter(|| render_shortcodes(CONTENT, &context)); |
|
|
b.iter(|| render_shortcodes(CONTENT, &context)); |
|
|
} |
|
|
} |
|
|