#![allow(dead_code)] #[macro_use] extern crate criterion; extern crate rion; #[macro_use] extern crate serde_derive; use criterion::Criterion; use rion::Rion; static TABLE_SOURCE: &str = " {{ for row in table }} {{ for value in row }}{value}{{ endfor }} {{ endfor }} "; #[derive(Serialize)] struct TableContext { table: Vec>, } fn make_table_context(size: usize) -> TableContext { 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); } TableContext { table } } fn parse(criterion: &mut Criterion) { criterion.bench_function("parse-table", |b| { b.iter(|| { let mut tt = Rion::new(); tt.add_template("table", TABLE_SOURCE) .expect("failed to add template") }); }); } // fn render(criterion: &mut Criterion) { // let mut tt = Rion::new(); // tt.add_template("table", TABLE_SOURCE).unwrap(); // // criterion.bench_with_input( // "render-table", // move |b, size| { // let data = make_table_context(*size); // // b.iter(|| tt.render("table", &data).unwrap()); // }, // vec![1usize, 5, 10, 50, 100, 200], // ); // } criterion_group!(benchmarks, parse); criterion_main!(benchmarks);