add benches
This commit is contained in:
parent
bea90060a8
commit
d61f8abd41
14
Cargo.toml
14
Cargo.toml
@ -22,6 +22,19 @@ name = "grass"
|
||||
path = "src/lib.rs"
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[[bench]]
|
||||
name = "numbers"
|
||||
harness = false
|
||||
|
||||
[[bench]]
|
||||
name = "control_flow"
|
||||
harness = false
|
||||
|
||||
[[bench]]
|
||||
name = "styles"
|
||||
harness = false
|
||||
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "2.33.0", optional = true }
|
||||
num-rational = "0.2.3"
|
||||
@ -49,6 +62,7 @@ profiling = []
|
||||
[dev-dependencies]
|
||||
tempfile = "3"
|
||||
paste = "0.1"
|
||||
criterion = "0.3.2"
|
||||
|
||||
[profile.release]
|
||||
debug = true
|
||||
|
11
benches/control_flow.rs
Normal file
11
benches/control_flow.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use grass::StyleSheet;
|
||||
|
||||
pub fn big_for(c: &mut Criterion) {
|
||||
c.bench_function("big_for", |b| {
|
||||
b.iter(|| StyleSheet::new(black_box(include_str!("big_for.scss").to_string())))
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(benches, big_for);
|
||||
criterion_main!(benches);
|
27
benches/numbers.rs
Normal file
27
benches/numbers.rs
Normal file
@ -0,0 +1,27 @@
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use grass::StyleSheet;
|
||||
|
||||
pub fn many_floats(c: &mut Criterion) {
|
||||
c.bench_function("many_floats", |b| {
|
||||
b.iter(|| StyleSheet::new(black_box(include_str!("many_floats.scss").to_string())))
|
||||
});
|
||||
}
|
||||
|
||||
pub fn many_integers(c: &mut Criterion) {
|
||||
c.bench_function("many_integers", |b| {
|
||||
b.iter(|| StyleSheet::new(black_box(include_str!("many_integers.scss").to_string())))
|
||||
});
|
||||
}
|
||||
|
||||
pub fn many_small_integers(c: &mut Criterion) {
|
||||
c.bench_function("many_small_integers", |b| {
|
||||
b.iter(|| {
|
||||
StyleSheet::new(black_box(
|
||||
include_str!("many_small_integers.scss").to_string(),
|
||||
))
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(benches, many_floats, many_integers, many_small_integers);
|
||||
criterion_main!(benches);
|
11
benches/styles.rs
Normal file
11
benches/styles.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use grass::StyleSheet;
|
||||
|
||||
pub fn many_foo(c: &mut Criterion) {
|
||||
c.bench_function("many_foo", |b| {
|
||||
b.iter(|| StyleSheet::new(black_box(include_str!("many_foo.scss").to_string())))
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(benches, many_foo);
|
||||
criterion_main!(benches);
|
Loading…
x
Reference in New Issue
Block a user