From fe37bab6f2859a4bbc9d4c81dfae38b400bd5660 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Wed, 20 May 2020 22:51:56 -0400 Subject: [PATCH] add color benchmarks --- Cargo.toml | 4 ++++ benches/colors.rs | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 benches/colors.rs diff --git a/Cargo.toml b/Cargo.toml index c23c280..65dea74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,10 @@ name = "grass" path = "src/lib.rs" crate-type = ["cdylib", "rlib"] +[[bench]] +name = "colors" +harness = false + [[bench]] name = "numbers" harness = false diff --git a/benches/colors.rs b/benches/colors.rs new file mode 100644 index 0000000..f4e63fc --- /dev/null +++ b/benches/colors.rs @@ -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);