maud/benchmarks/benches/maud.rs
Eshin Kunishima 3a3e55429a Update dependencies for benchmarks ()
* Update dependencies for benchmarks

Template engines
- maud 0.17.1 (local)
- handlebars 0.29.1
- horrorshow 0.6.2
- liquid 0.10.1
- tera 0.10.10

* Update benchmark dependencies

* Remove unused feature

* Revert indentation

* Fix unused Result
2017-09-30 17:16:21 +13:00

44 lines
1 KiB
Rust

#![feature(plugin, test)]
#![feature(proc_macro)]
extern crate maud;
use maud::html;
extern crate test;
#[derive(Debug)]
struct Entry {
name: &'static str,
score: u16,
}
#[bench]
fn render_template(b: &mut test::Bencher) {
let year = test::black_box("2015");
let teams = test::black_box(vec![
Entry { name: "Jiangsu", score: 43 },
Entry { name: "Beijing", score: 27 },
Entry { name: "Guangzhou", score: 22 },
Entry { name: "Shandong", score: 12 },
]);
b.iter(|| {
html! {
html {
head {
title (year)
}
body {
h1 { "CSL " (year) }
ul {
@for (i, team) in teams.iter().enumerate() {
li.champion[i == 0] {
b (team.name) ": " (team.score)
}
}
}
}
}
}
});
}