Update benchmarks
This commit is contained in:
parent
39f543c819
commit
d7620f04c8
9 changed files with 411 additions and 271 deletions
646
benchmarks/Cargo.lock
generated
646
benchmarks/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -2,6 +2,7 @@
|
||||||
name = "benchmarks"
|
name = "benchmarks"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
authors = ["Chris Wong <lambda.fairy@gmail.com>"]
|
authors = ["Chris Wong <lambda.fairy@gmail.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
maud = { path = "../maud" }
|
maud = { path = "../maud" }
|
||||||
|
@ -10,7 +11,6 @@ horrorshow = "*"
|
||||||
liquid = "*"
|
liquid = "*"
|
||||||
rustc-serialize = "*"
|
rustc-serialize = "*"
|
||||||
serde = "*"
|
serde = "*"
|
||||||
serde_derive = "*"
|
|
||||||
serde_json = "*"
|
serde_json = "*"
|
||||||
tera = "*"
|
tera = "*"
|
||||||
askama = "*"
|
askama = "*"
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
|
|
||||||
extern crate askama;
|
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
||||||
use askama::Template;
|
use askama::Template;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
#![feature(proc_macro_hygiene)]
|
#![feature(proc_macro_hygiene)]
|
||||||
|
|
||||||
extern crate maud;
|
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
||||||
use maud::{Markup, html};
|
use maud::{Markup, html};
|
||||||
|
@ -84,7 +83,7 @@ fn render_complicated_template(b: &mut test::Bencher) {
|
||||||
Entry { name: "Shandong", score: 12 },
|
Entry { name: "Shandong", score: 12 },
|
||||||
]);
|
]);
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
use btn::{Button, RequestMethod};
|
use crate::btn::{Button, RequestMethod};
|
||||||
layout(format!("Homepage of {}", year), html! {
|
layout(format!("Homepage of {}", year), html! {
|
||||||
h1 { "Hello there!" }
|
h1 { "Hello there!" }
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
|
|
||||||
extern crate handlebars;
|
|
||||||
extern crate test;
|
extern crate test;
|
||||||
extern crate serde_json;
|
|
||||||
|
|
||||||
use serde_json::value::{Map, Value as Json};
|
use serde_json::value::{Map, Value as Json};
|
||||||
use handlebars::{to_json, Handlebars};
|
use handlebars::{to_json, Handlebars};
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
|
|
||||||
|
// TODO https://github.com/Stebalien/horrorshow-rs/issues/26
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate horrorshow;
|
extern crate horrorshow;
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
|
|
||||||
extern crate liquid;
|
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
||||||
use liquid::{Object, ParserBuilder, Value};
|
use liquid::ParserBuilder;
|
||||||
|
use liquid::value::{Object, Value};
|
||||||
|
|
||||||
// FIXME(cobalt-org/liquid-rust#47): "for_loop" should be "forloop" instead
|
|
||||||
static SOURCE: &'static str = "<html>
|
static SOURCE: &'static str = "<html>
|
||||||
<head>
|
<head>
|
||||||
<title>{{year}}</title>
|
<title>{{year}}</title>
|
||||||
|
@ -14,7 +13,7 @@ static SOURCE: &'static str = "<html>
|
||||||
<h1>CSL {{year}}</h1>
|
<h1>CSL {{year}}</h1>
|
||||||
<ul>
|
<ul>
|
||||||
{% for team in teams %}
|
{% for team in teams %}
|
||||||
<li class=\"{% if for_loop.first %}champion{% endif %}\">
|
<li class=\"{% if forloop.first %}champion{% endif %}\">
|
||||||
<b>{{team.name}}</b>: {{team.score}}
|
<b>{{team.name}}</b>: {{team.score}}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -24,24 +23,24 @@ static SOURCE: &'static str = "<html>
|
||||||
|
|
||||||
fn make_team(name: &'static str, score: u16) -> Value {
|
fn make_team(name: &'static str, score: u16) -> Value {
|
||||||
let mut team = Object::new();
|
let mut team = Object::new();
|
||||||
team.insert("name".to_owned(), Value::scalar(name.to_string()));
|
team.insert("name".into(), Value::scalar(name));
|
||||||
team.insert("score".to_owned(), Value::scalar(score as i32));
|
team.insert("score".into(), Value::scalar(score as i32));
|
||||||
Value::Object(team)
|
Value::Object(team)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn render_template(b: &mut test::Bencher) {
|
fn render_template(b: &mut test::Bencher) {
|
||||||
let template = test::black_box(ParserBuilder::with_liquid().build().parse(SOURCE).unwrap());
|
let template = test::black_box(ParserBuilder::with_liquid().build().unwrap().parse(SOURCE).unwrap());
|
||||||
let mut globals = test::black_box({
|
let mut globals = test::black_box({
|
||||||
let mut globals = Object::new();
|
let mut globals = Object::new();
|
||||||
globals.insert("year".to_owned(), Value::scalar(2015));
|
globals.insert("year".into(), Value::scalar(2015));
|
||||||
let teams = vec![
|
let teams = vec![
|
||||||
make_team("Jiangsu", 43),
|
make_team("Jiangsu", 43),
|
||||||
make_team("Beijing", 27),
|
make_team("Beijing", 27),
|
||||||
make_team("Guangzhou", 22),
|
make_team("Guangzhou", 22),
|
||||||
make_team("Shandong", 12),
|
make_team("Shandong", 12),
|
||||||
];
|
];
|
||||||
globals.insert("teams".to_owned(), Value::Array(teams));
|
globals.insert("teams".into(), Value::Array(teams));
|
||||||
globals
|
globals
|
||||||
});
|
});
|
||||||
b.iter(|| template.render(&mut globals).unwrap());
|
b.iter(|| template.render(&mut globals).unwrap());
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
#![feature(proc_macro_hygiene)]
|
#![feature(proc_macro_hygiene)]
|
||||||
|
|
||||||
extern crate maud;
|
|
||||||
|
|
||||||
use maud::html;
|
use maud::html;
|
||||||
|
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate serde_derive;
|
|
||||||
extern crate tera;
|
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
||||||
|
use serde::Serialize;
|
||||||
use tera::{Context, Tera};
|
use tera::{Context, Tera};
|
||||||
|
|
||||||
#[derive(Serialize, Debug)]
|
#[derive(Serialize, Debug)]
|
||||||
|
@ -36,13 +34,13 @@ fn render_template(b: &mut test::Bencher) {
|
||||||
|
|
||||||
let context = test::black_box({
|
let context = test::black_box({
|
||||||
let mut context = Context::new();
|
let mut context = Context::new();
|
||||||
context.add("teams", &[
|
context.insert("teams", &[
|
||||||
Entry { name: "Jiangsu", score: 43 },
|
Entry { name: "Jiangsu", score: 43 },
|
||||||
Entry { name: "Beijing", score: 27 },
|
Entry { name: "Beijing", score: 27 },
|
||||||
Entry { name: "Guangzhou", score: 22 },
|
Entry { name: "Guangzhou", score: 22 },
|
||||||
Entry { name: "Shandong", score: 12 },
|
Entry { name: "Shandong", score: 12 },
|
||||||
]);
|
]);
|
||||||
context.add("year", &"2015");
|
context.insert("year", &"2015");
|
||||||
context
|
context
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue