add color benchmarks

This commit is contained in:
ConnorSkees 2020-05-20 22:51:56 -04:00
parent 3decf3739c
commit fe37bab6f2
2 changed files with 25 additions and 0 deletions

View File

@ -22,6 +22,10 @@ name = "grass"
path = "src/lib.rs"
crate-type = ["cdylib", "rlib"]
[[bench]]
name = "colors"
harness = false
[[bench]]
name = "numbers"
harness = false

21
benches/colors.rs Normal file
View File

@ -0,0 +1,21 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use grass::StyleSheet;
pub fn many_hsla(c: &mut Criterion) {
c.bench_function("many_hsla", |b| {
b.iter(|| StyleSheet::new(black_box(include_str!("many_hsla.scss").to_string())))
});
}
pub fn many_named_colors(c: &mut Criterion) {
c.bench_function("many_named_colors", |b| {
b.iter(|| {
StyleSheet::new(black_box(
include_str!("many_named_colors.scss").to_string(),
))
})
});
}
criterion_group!(benches, many_hsla, many_named_colors,);
criterion_main!(benches);