#![feature(test)] extern crate tera; extern crate test; #[macro_use] extern crate serde_derive; // Benches from https://github.com/djc/template-benchmarks-rs use tera::{Context, Tera}; #[bench] pub fn big_table(b: &mut test::Bencher) { // 100 instead of 50 in the original benchmark to make the time bigger let size = 100; let mut table = Vec::with_capacity(size); for _ in 0..size { let mut inner = Vec::with_capacity(size); for i in 0..size { inner.push(i); } table.push(inner); } let mut tera = Tera::default(); tera.add_raw_templates(vec![("big-table.html", BIG_TABLE_TEMPLATE)]).unwrap(); let mut ctx = Context::new(); ctx.insert("table", &table); b.iter(|| tera.render("big-table.html", ctx.clone())); } static BIG_TABLE_TEMPLATE: &'static str = "
{{ col }} | {% endfor %}