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"
|
||||
version = "0.1.2"
|
||||
authors = ["Chris Wong <lambda.fairy@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
maud = { path = "../maud" }
|
||||
|
@ -10,7 +11,6 @@ horrorshow = "*"
|
|||
liquid = "*"
|
||||
rustc-serialize = "*"
|
||||
serde = "*"
|
||||
serde_derive = "*"
|
||||
serde_json = "*"
|
||||
tera = "*"
|
||||
askama = "*"
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#![feature(test)]
|
||||
|
||||
extern crate askama;
|
||||
extern crate test;
|
||||
|
||||
use askama::Template;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#![feature(test)]
|
||||
#![feature(proc_macro_hygiene)]
|
||||
|
||||
extern crate maud;
|
||||
extern crate test;
|
||||
|
||||
use maud::{Markup, html};
|
||||
|
@ -84,7 +83,7 @@ fn render_complicated_template(b: &mut test::Bencher) {
|
|||
Entry { name: "Shandong", score: 12 },
|
||||
]);
|
||||
b.iter(|| {
|
||||
use btn::{Button, RequestMethod};
|
||||
use crate::btn::{Button, RequestMethod};
|
||||
layout(format!("Homepage of {}", year), html! {
|
||||
h1 { "Hello there!" }
|
||||
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
#![feature(test)]
|
||||
|
||||
extern crate handlebars;
|
||||
extern crate test;
|
||||
extern crate serde_json;
|
||||
|
||||
use serde_json::value::{Map, Value as Json};
|
||||
use handlebars::{to_json, Handlebars};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#![feature(test)]
|
||||
|
||||
// TODO https://github.com/Stebalien/horrorshow-rs/issues/26
|
||||
#[macro_use]
|
||||
extern crate horrorshow;
|
||||
extern crate test;
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
#![feature(test)]
|
||||
|
||||
extern crate liquid;
|
||||
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>
|
||||
<head>
|
||||
<title>{{year}}</title>
|
||||
|
@ -14,7 +13,7 @@ static SOURCE: &'static str = "<html>
|
|||
<h1>CSL {{year}}</h1>
|
||||
<ul>
|
||||
{% 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}}
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
@ -24,24 +23,24 @@ static SOURCE: &'static str = "<html>
|
|||
|
||||
fn make_team(name: &'static str, score: u16) -> Value {
|
||||
let mut team = Object::new();
|
||||
team.insert("name".to_owned(), Value::scalar(name.to_string()));
|
||||
team.insert("score".to_owned(), Value::scalar(score as i32));
|
||||
team.insert("name".into(), Value::scalar(name));
|
||||
team.insert("score".into(), Value::scalar(score as i32));
|
||||
Value::Object(team)
|
||||
}
|
||||
|
||||
#[bench]
|
||||
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 = Object::new();
|
||||
globals.insert("year".to_owned(), Value::scalar(2015));
|
||||
globals.insert("year".into(), Value::scalar(2015));
|
||||
let teams = vec![
|
||||
make_team("Jiangsu", 43),
|
||||
make_team("Beijing", 27),
|
||||
make_team("Guangzhou", 22),
|
||||
make_team("Shandong", 12),
|
||||
];
|
||||
globals.insert("teams".to_owned(), Value::Array(teams));
|
||||
globals.insert("teams".into(), Value::Array(teams));
|
||||
globals
|
||||
});
|
||||
b.iter(|| template.render(&mut globals).unwrap());
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#![feature(test)]
|
||||
#![feature(proc_macro_hygiene)]
|
||||
|
||||
extern crate maud;
|
||||
|
||||
use maud::html;
|
||||
|
||||
extern crate test;
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#![feature(test)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
extern crate tera;
|
||||
extern crate test;
|
||||
|
||||
use serde::Serialize;
|
||||
use tera::{Context, Tera};
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
|
@ -36,13 +34,13 @@ fn render_template(b: &mut test::Bencher) {
|
|||
|
||||
let context = test::black_box({
|
||||
let mut context = Context::new();
|
||||
context.add("teams", &[
|
||||
context.insert("teams", &[
|
||||
Entry { name: "Jiangsu", score: 43 },
|
||||
Entry { name: "Beijing", score: 27 },
|
||||
Entry { name: "Guangzhou", score: 22 },
|
||||
Entry { name: "Shandong", score: 12 },
|
||||
]);
|
||||
context.add("year", &"2015");
|
||||
context.insert("year", &"2015");
|
||||
context
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue