|
| 1 | +#[macro_use] |
| 2 | +extern crate criterion; |
| 3 | +extern crate flat_tree; |
| 4 | + |
| 5 | +use criterion::Criterion; |
| 6 | + |
| 7 | +fn criterion_benchmark(c: &mut Criterion) { |
| 8 | + c.bench_function("children_9", |b| b.iter(|| flat_tree::children(9))); |
| 9 | + c.bench_function("children_256", |b| b.iter(|| flat_tree::children(256))); |
| 10 | + c.bench_function("count_128", |b| b.iter(|| flat_tree::count(128))); |
| 11 | + c.bench_function("depth_128", |b| b.iter(|| flat_tree::depth(128))); |
| 12 | + // c.bench_function("full_roots_16", |b| { |
| 13 | + // let mut nodes: Vec<usize> = Vec::with_capacity(16); |
| 14 | + // b.iter(|| { |
| 15 | + // flat_tree::full_roots(16, &mut nodes); |
| 16 | + // }) |
| 17 | + // }); |
| 18 | + // c.bench_function("full_roots_256", |b| { |
| 19 | + // let mut nodes: Vec<usize> = Vec::with_capacity(16); |
| 20 | + // b.iter(|| { |
| 21 | + // flat_tree::full_roots(256, &mut nodes); |
| 22 | + // }) |
| 23 | + // }); |
| 24 | + c.bench_function("index_3_1", |b| b.iter(|| flat_tree::index(3, 1))); |
| 25 | + c.bench_function("left_child_128", |b| b.iter(|| flat_tree::left_child(128))); |
| 26 | + c.bench_function("left_span_128", |b| b.iter(|| flat_tree::left_span(128))); |
| 27 | + c.bench_function("offset_128", |b| b.iter(|| flat_tree::offset(128))); |
| 28 | + c.bench_function("parent_128", |b| b.iter(|| flat_tree::parent(128))); |
| 29 | + c.bench_function("right_child_128", |b| { |
| 30 | + b.iter(|| flat_tree::right_child(128)) |
| 31 | + }); |
| 32 | + c.bench_function("right_span_128", |b| b.iter(|| flat_tree::right_span(128))); |
| 33 | + c.bench_function("sibling_128", |b| b.iter(|| flat_tree::sibling(128))); |
| 34 | + c.bench_function("spans_128", |b| b.iter(|| flat_tree::spans(128))); |
| 35 | + c.bench_function("uncle_128", |b| b.iter(|| flat_tree::uncle(128))); |
| 36 | +} |
| 37 | + |
| 38 | +criterion_group!(benches, criterion_benchmark); |
| 39 | +criterion_main!(benches); |
0 commit comments