Fix yarte fixed bench
This commit is contained in:
parent
dad577db8b
commit
86658d4a96
|
@ -1,3 +1,5 @@
|
||||||
|
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) {
|
||||||
|
@ -11,13 +13,11 @@ pub fn big_table(b: &mut criterion::Bencher<'_>, size: &usize) {
|
||||||
}
|
}
|
||||||
let ctx = BigTable { table };
|
let ctx = BigTable { table };
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let mut buf = String::with_capacity(109915);
|
|
||||||
unsafe {
|
unsafe {
|
||||||
buf.as_mut_vec().set_len(109915);
|
let mut buf: [u8; 109915] = MaybeUninit::uninit().assume_init();
|
||||||
let b = ctx.call(buf.as_bytes_mut()).unwrap();
|
let b = ctx.call(&mut buf).unwrap();
|
||||||
buf.as_mut_vec().set_len(b);
|
let _ = &buf[..b];
|
||||||
}
|
}
|
||||||
buf
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,13 +51,11 @@ pub fn teams(b: &mut criterion::Bencher<'_>) {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let mut buf = String::with_capacity(239);
|
|
||||||
unsafe {
|
unsafe {
|
||||||
buf.as_mut_vec().set_len(239);
|
let mut buf: [u8; 239] = MaybeUninit::uninit().assume_init();
|
||||||
let b = teams.call(buf.as_bytes_mut()).unwrap();
|
let b = teams.call(&mut buf).unwrap();
|
||||||
buf.as_mut_vec().set_len(b);
|
let _ = &buf[..b];
|
||||||
}
|
}
|
||||||
buf
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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