Add and specify behaviours for yarte benches
This commit is contained in:
parent
3a6ef334d4
commit
d07161918b
|
@ -1,7 +1,8 @@
|
|||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use benches::{
|
||||
askama_bench, fomat, horrorshow_bench, markup_bench, sailfish, std_write, yarte_bench, yarte_fixed
|
||||
askama_bench, fomat, horrorshow_bench, markup_bench, sailfish, std_write,
|
||||
yarte_bench, yarte_bytes, yarte_fixed,
|
||||
};
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
|
||||
fn big_table(c: &mut Criterion) {
|
||||
let mut g = c.benchmark_group("Big table");
|
||||
|
@ -10,7 +11,8 @@ fn big_table(c: &mut Criterion) {
|
|||
g.bench_function("Horrorshow", |b| horrorshow_bench::big_table(b, &100));
|
||||
g.bench_function("Markup", |b| markup_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("sailfish", |b| sailfish::big_table(b, &100));
|
||||
g.finish();
|
||||
|
@ -23,7 +25,8 @@ fn teams(c: &mut Criterion) {
|
|||
g.bench_function("Horrorshow", |b| horrorshow_bench::teams(b, &0));
|
||||
g.bench_function("Markup", |b| markup_bench::teams(b, &0));
|
||||
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("sailfish", |b| sailfish::teams(b));
|
||||
g.finish();
|
||||
|
|
|
@ -5,4 +5,5 @@ pub mod markup_bench;
|
|||
pub mod sailfish;
|
||||
pub mod std_write;
|
||||
pub mod yarte_bench;
|
||||
pub mod yarte_bytes;
|
||||
pub mod yarte_fixed;
|
||||
|
|
|
@ -42,7 +42,7 @@ pub fn teams(b: &mut criterion::Bencher<'_>) {
|
|||
b.iter(|| {
|
||||
let teams = TeamsTemplate {
|
||||
year: teams.year,
|
||||
teams: &teams.teams
|
||||
teams: &teams.teams,
|
||||
};
|
||||
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,4 +1,6 @@
|
|||
use yarte::TemplateBytes;
|
||||
use criterion::black_box;
|
||||
use std::mem::MaybeUninit;
|
||||
use yarte::TemplateFixed;
|
||||
|
||||
pub fn big_table(b: &mut criterion::Bencher<'_>, size: &usize) {
|
||||
let mut table = Vec::with_capacity(*size);
|
||||
|
@ -11,11 +13,11 @@ pub fn big_table(b: &mut criterion::Bencher<'_>, size: &usize) {
|
|||
}
|
||||
let t = BigTable { table };
|
||||
b.iter(|| {
|
||||
t.call(109915).unwrap()
|
||||
black_box(t.call(&mut [MaybeUninit::uninit(); 109915]).unwrap());
|
||||
});
|
||||
}
|
||||
|
||||
#[derive(TemplateBytes)]
|
||||
#[derive(TemplateFixed)]
|
||||
#[template(path = "big-table")]
|
||||
struct BigTable {
|
||||
table: Vec<Vec<usize>>,
|
||||
|
@ -45,11 +47,11 @@ pub fn teams(b: &mut criterion::Bencher<'_>) {
|
|||
],
|
||||
};
|
||||
b.iter(|| {
|
||||
t.call(239).unwrap()
|
||||
black_box(t.call(&mut [MaybeUninit::uninit(); 239]).unwrap());
|
||||
});
|
||||
}
|
||||
|
||||
#[derive(TemplateBytes)]
|
||||
#[derive(TemplateFixed)]
|
||||
#[template(path = "teams")]
|
||||
struct Teams {
|
||||
year: u16,
|
||||
|
|
Loading…
Reference in New Issue