Merge pull request #12 from 'botika/master'
This commit is contained in:
commit
a48b67433e
|
@ -169,9 +169,9 @@ checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.12.1"
|
version = "0.12.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "53d1ccbaf7d9ec9537465a97bf19edc1a4e158ecb49fc16178202238c569cc42"
|
checksum = "e223af0dc48c96d4f8342ec01a4974f139df863896b316681efd36742f22cc67"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "beef"
|
name = "beef"
|
||||||
|
@ -287,6 +287,12 @@ version = "1.3.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
|
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bytes"
|
||||||
|
version = "0.5.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cast"
|
name = "cast"
|
||||||
version = "0.2.3"
|
version = "0.2.3"
|
||||||
|
@ -835,7 +841,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "handlebars"
|
name = "handlebars"
|
||||||
version = "3.1.1-alpha.0"
|
version = "3.1.1-alpha.0"
|
||||||
source = "git+https://github.com/sunng87/handlebars-rust#87b25985c4cd1a7babc78ccf28a592a44474c133"
|
source = "git+https://github.com/sunng87/handlebars-rust#3a5e50b24e471a1ea49c7a33dcfc89f68db385c4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"pest",
|
"pest",
|
||||||
|
@ -1362,7 +1368,7 @@ version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7b336d94e8e4ce29bf15bba393164629764744c567e8ad306cc1fdd0119967fd"
|
checksum = "7b336d94e8e4ce29bf15bba393164629764744c567e8ad306cc1fdd0119967fd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.12.1",
|
"base64 0.12.2",
|
||||||
"chrono",
|
"chrono",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"line-wrap",
|
"line-wrap",
|
||||||
|
@ -1562,10 +1568,11 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rayon"
|
name = "rayon"
|
||||||
version = "1.3.0"
|
version = "1.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098"
|
checksum = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
"crossbeam-deque",
|
"crossbeam-deque",
|
||||||
"either",
|
"either",
|
||||||
"rayon-core",
|
"rayon-core",
|
||||||
|
@ -1573,9 +1580,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rayon-core"
|
name = "rayon-core"
|
||||||
version = "1.7.0"
|
version = "1.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9"
|
checksum = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crossbeam-deque",
|
"crossbeam-deque",
|
||||||
"crossbeam-queue",
|
"crossbeam-queue",
|
||||||
|
@ -1642,7 +1649,7 @@ name = "ructe"
|
||||||
version = "0.11.5-PRE"
|
version = "0.11.5-PRE"
|
||||||
source = "git+https://github.com/kaj/ructe#0d8ffc1a4e920fc591f19c7fcc126825c3da8745"
|
source = "git+https://github.com/kaj/ructe#0d8ffc1a4e920fc591f19c7fcc126825c3da8745"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.12.1",
|
"base64 0.12.2",
|
||||||
"bytecount",
|
"bytecount",
|
||||||
"itertools 0.9.0",
|
"itertools 0.9.0",
|
||||||
"md5",
|
"md5",
|
||||||
|
@ -2323,8 +2330,9 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yarte"
|
name = "yarte"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://github.com/botika/yarte#7210239d274aced48e8f7c3466058784202eb941"
|
source = "git+https://github.com/botika/yarte#dbd1a379fc333e995bfc2c055761fea48f566808"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
"yarte_derive",
|
"yarte_derive",
|
||||||
"yarte_helpers",
|
"yarte_helpers",
|
||||||
]
|
]
|
||||||
|
@ -2332,7 +2340,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yarte_codegen"
|
name = "yarte_codegen"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://github.com/botika/yarte#7210239d274aced48e8f7c3466058784202eb941"
|
source = "git+https://github.com/botika/yarte#dbd1a379fc333e995bfc2c055761fea48f566808"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
|
@ -2344,7 +2352,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yarte_derive"
|
name = "yarte_derive"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://github.com/botika/yarte#7210239d274aced48e8f7c3466058784202eb941"
|
source = "git+https://github.com/botika/yarte#dbd1a379fc333e995bfc2c055761fea48f566808"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"prettyprint",
|
"prettyprint",
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
|
@ -2361,7 +2369,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yarte_helpers"
|
name = "yarte_helpers"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://github.com/botika/yarte#7210239d274aced48e8f7c3466058784202eb941"
|
source = "git+https://github.com/botika/yarte#dbd1a379fc333e995bfc2c055761fea48f566808"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dtoa",
|
"dtoa",
|
||||||
"itoa",
|
"itoa",
|
||||||
|
@ -2373,7 +2381,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yarte_hir"
|
name = "yarte_hir"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://github.com/botika/yarte#7210239d274aced48e8f7c3466058784202eb941"
|
source = "git+https://github.com/botika/yarte#dbd1a379fc333e995bfc2c055761fea48f566808"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_more",
|
"derive_more",
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
|
@ -2388,7 +2396,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yarte_parser"
|
name = "yarte_parser"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://github.com/botika/yarte#7210239d274aced48e8f7c3466058784202eb941"
|
source = "git+https://github.com/botika/yarte#dbd1a379fc333e995bfc2c055761fea48f566808"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"annotate-snippets",
|
"annotate-snippets",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
|
|
|
@ -23,7 +23,7 @@ serde_derive = "1"
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
serde_yaml = "0.8"
|
serde_yaml = "0.8"
|
||||||
tera = { git = "https://github.com/Keats/tera" }
|
tera = { git = "https://github.com/Keats/tera" }
|
||||||
yarte = { git = "https://github.com/botika/yarte", features = ["fixed"] }
|
yarte = { git = "https://github.com/botika/yarte", features = ["bytes_buff"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
ructe = { git = "https://github.com/kaj/ructe" }
|
ructe = { git = "https://github.com/kaj/ructe" }
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use criterion::{criterion_group, criterion_main, Criterion};
|
|
||||||
use benches::{
|
use benches::{
|
||||||
askama_bench, fomat, handlebars, horrorshow_bench, liquid, markup_bench, maud_bench,
|
askama_bench, fomat, handlebars, horrorshow_bench, liquid, markup_bench, maud_bench,
|
||||||
ramhorns, ructe, sailfish, std_write, tera, yarte_bench, yarte_fixed,
|
ramhorns, ructe, sailfish, std_write, tera, yarte_bench, yarte_bytes, yarte_fixed,
|
||||||
};
|
};
|
||||||
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
|
|
||||||
fn big_table(c: &mut Criterion) {
|
fn big_table(c: &mut Criterion) {
|
||||||
let mut g = c.benchmark_group("Big table");
|
let mut g = c.benchmark_group("Big table");
|
||||||
|
@ -18,7 +18,8 @@ fn big_table(c: &mut Criterion) {
|
||||||
g.bench_function("Sailfish", |b| sailfish::big_table(b, &100));
|
g.bench_function("Sailfish", |b| sailfish::big_table(b, &100));
|
||||||
g.bench_function("Tera", |b| tera::big_table(b, &100));
|
g.bench_function("Tera", |b| tera::big_table(b, &100));
|
||||||
g.bench_function("Yarte", |b| yarte_bench::big_table(b, &100));
|
g.bench_function("Yarte", |b| yarte_bench::big_table(b, &100));
|
||||||
g.bench_function("Yarte Fixed", |b| yarte_fixed::big_table(b, &100));
|
g.bench_function("Yarte Send", |b| yarte_bytes::big_table(b, &100));
|
||||||
|
g.bench_function("Yarte ?Send", |b| yarte_fixed::big_table(b, &100));
|
||||||
g.bench_function("write", |b| std_write::big_table(b, &100));
|
g.bench_function("write", |b| std_write::big_table(b, &100));
|
||||||
g.finish();
|
g.finish();
|
||||||
}
|
}
|
||||||
|
@ -37,7 +38,8 @@ fn teams(c: &mut Criterion) {
|
||||||
g.bench_function("Sailfish", |b| sailfish::teams(b));
|
g.bench_function("Sailfish", |b| sailfish::teams(b));
|
||||||
g.bench_function("Tera", |b| tera::teams(b, &0));
|
g.bench_function("Tera", |b| tera::teams(b, &0));
|
||||||
g.bench_function("Yarte", |b| yarte_bench::teams(b));
|
g.bench_function("Yarte", |b| yarte_bench::teams(b));
|
||||||
g.bench_function("Yarte Fixed", |b| yarte_fixed::teams(b));
|
g.bench_function("Yarte Send", |b| yarte_bytes::teams(b));
|
||||||
|
g.bench_function("Yarte ?Send", |b| yarte_fixed::teams(b));
|
||||||
g.bench_function("write", |b| std_write::teams(b, &0));
|
g.bench_function("write", |b| std_write::teams(b, &0));
|
||||||
g.finish();
|
g.finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ pub mod sailfish;
|
||||||
pub mod std_write;
|
pub mod std_write;
|
||||||
pub mod tera;
|
pub mod tera;
|
||||||
pub mod yarte_bench;
|
pub mod yarte_bench;
|
||||||
|
pub mod yarte_bytes;
|
||||||
pub mod yarte_fixed;
|
pub mod yarte_fixed;
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/templates.rs"));
|
include!(concat!(env!("OUT_DIR"), "/templates.rs"));
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub fn teams(b: &mut criterion::Bencher<'_>) {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let teams = TeamsTemplate {
|
let teams = TeamsTemplate {
|
||||||
year: teams.year,
|
year: teams.year,
|
||||||
teams: &teams.teams
|
teams: &teams.teams,
|
||||||
};
|
};
|
||||||
teams.render_once().unwrap()
|
teams.render_once().unwrap()
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
use yarte::TemplateBytes;
|
||||||
|
|
||||||
|
pub fn big_table(b: &mut criterion::Bencher<'_>, size: &usize) {
|
||||||
|
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 t = BigTable { table };
|
||||||
|
b.iter(|| t.call(109915).unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(TemplateBytes)]
|
||||||
|
#[template(path = "big-table")]
|
||||||
|
struct BigTable {
|
||||||
|
table: Vec<Vec<usize>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn teams(b: &mut criterion::Bencher<'_>) {
|
||||||
|
let t = Teams {
|
||||||
|
year: 2015,
|
||||||
|
teams: vec![
|
||||||
|
Team {
|
||||||
|
name: "Jiangsu".into(),
|
||||||
|
|
||||||
|
score: 43,
|
||||||
|
},
|
||||||
|
Team {
|
||||||
|
name: "Beijing".into(),
|
||||||
|
score: 27,
|
||||||
|
},
|
||||||
|
Team {
|
||||||
|
name: "Guangzhou".into(),
|
||||||
|
score: 22,
|
||||||
|
},
|
||||||
|
Team {
|
||||||
|
name: "Shandong".into(),
|
||||||
|
score: 12,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
b.iter(|| t.call(239).unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(TemplateBytes)]
|
||||||
|
#[template(path = "teams")]
|
||||||
|
struct Teams {
|
||||||
|
year: u16,
|
||||||
|
teams: Vec<Team>,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Team {
|
||||||
|
name: String,
|
||||||
|
score: u8,
|
||||||
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
|
use criterion::black_box;
|
||||||
|
use std::mem::MaybeUninit;
|
||||||
use yarte::TemplateFixed;
|
use yarte::TemplateFixed;
|
||||||
|
|
||||||
pub fn big_table(b: &mut criterion::Bencher<'_>, size: &usize) {
|
pub fn big_table(b: &mut criterion::Bencher<'_>, size: &usize) {
|
||||||
|
@ -9,26 +11,20 @@ pub fn big_table(b: &mut criterion::Bencher<'_>, size: &usize) {
|
||||||
}
|
}
|
||||||
table.push(inner);
|
table.push(inner);
|
||||||
}
|
}
|
||||||
let ctx = BigTable { table };
|
let t = BigTable { table };
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let mut buf = String::with_capacity(109915);
|
black_box(t.call(&mut [MaybeUninit::uninit(); 109915]).unwrap());
|
||||||
unsafe {
|
|
||||||
buf.as_mut_vec().set_len(109915);
|
|
||||||
let b = ctx.call(buf.as_bytes_mut()).unwrap();
|
|
||||||
buf.as_mut_vec().set_len(b);
|
|
||||||
}
|
|
||||||
buf
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(TemplateFixed)]
|
#[derive(TemplateFixed)]
|
||||||
#[template(path = "big-table.hbs")]
|
#[template(path = "big-table")]
|
||||||
struct BigTable {
|
struct BigTable {
|
||||||
table: Vec<Vec<usize>>,
|
table: Vec<Vec<usize>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn teams(b: &mut criterion::Bencher<'_>) {
|
pub fn teams(b: &mut criterion::Bencher<'_>) {
|
||||||
let teams = Teams {
|
let t = Teams {
|
||||||
year: 2015,
|
year: 2015,
|
||||||
teams: vec![
|
teams: vec![
|
||||||
Team {
|
Team {
|
||||||
|
@ -51,18 +47,12 @@ pub fn teams(b: &mut criterion::Bencher<'_>) {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let mut buf = String::with_capacity(239);
|
black_box(t.call(&mut [MaybeUninit::uninit(); 239]).unwrap());
|
||||||
unsafe {
|
|
||||||
buf.as_mut_vec().set_len(239);
|
|
||||||
let b = teams.call(buf.as_bytes_mut()).unwrap();
|
|
||||||
buf.as_mut_vec().set_len(b);
|
|
||||||
}
|
|
||||||
buf
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(TemplateFixed)]
|
#[derive(TemplateFixed)]
|
||||||
#[template(path = "teams.hbs")]
|
#[template(path = "teams")]
|
||||||
struct Teams {
|
struct Teams {
|
||||||
year: u16,
|
year: u16,
|
||||||
teams: Vec<Team>,
|
teams: Vec<Team>,
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<table>{{#each table}}<tr>{{#each this}}<td>{{ this }}</td>{{/each}}</tr>{{/each}}</table>
|
<table>{{#each table}}<tr>{{#each this}}<td>{{ this }}</td>{{/each }}</tr>{{/each }}</table>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<html><head><title>{{ year }}</title></head><body><h1>CSL {{ year }}</h1><ul>{{#each teams }}<li class="{{#if index0 == 0 }}champion{{/if}}"><b>{{ name }}</b>: {{ score }}</li>{{/each}}</ul></body></html>
|
<html><head><title>{{ year }}</title></head><body><h1>CSL {{ year }}</h1><ul>{{#each teams }}<li class="{{#if first }}champion{{/if }}"><b>{{ name }}</b>: {{ score }}</li>{{/each }}</ul></body></html>
|
||||||
|
|
Loading…
Reference in New Issue