/// Benchmarking for the merging of time series #[macro_use] extern crate criterion; extern crate tusk_data; use criterion::Criterion; fn bench_metadata(c: &mut Criterion) { { let mut mdf = tusk_data::metadata::MetaData::new(); mdf.add_label("first", "^hello$"); mdf.add_label("second", ".*batman"); mdf.add_label("third", ".*"); let mut md = tusk_data::metadata::MetaData::new(); md.add_label("first", "hello"); md.add_label("second", "robin and batman"); md.add_label("third", "some longer piece of information than you would probably find in the real world"); c.bench_function("matching metadata", move |b| { let x = mdf.clone(); let y = md.clone(); b.iter( || x.compile() .is_match(&y) ) }); } { let mut mdf = tusk_data::metadata::MetaData::new(); mdf.add_label("first", "^hello$"); mdf.add_label("second", ".*nanananana$"); mdf.add_label("third", ".*"); let mut md = tusk_data::metadata::MetaData::new(); md.add_label("first", "hello"); md.add_label("second", "robin and batman"); md.add_label("third", "some longer piece of information than you would probably find in the real world"); c.bench_function("not matching metadata", move |b| { let x = mdf.clone(); let y = md.clone(); b.iter( || x.compile() .is_match(&y) ) }); } { let mut md1 = tusk_data::metadata::MetaData::new(); md1.add_label("first", "first"); md1.add_label("second", "second"); md1.add_label("third", "third"); md1.add_label("fourth", "fourth"); md1.add_label("fifth", "fifth"); md1.add_label("sixth", "sixth"); md1.add_label("seventh", "seventh"); md1.add_label("eigth", "eigth"); let mut md2 = md1.clone(); md2.add_label("first", "hello"); md2.add_label("second", "robin and batman"); md2.add_label("third", "some longer piece of information than you would probably find in the real world"); c.bench_function("superset metadata", move |b| { let x = md1.clone(); let y = md2.clone(); b.iter( move || y.superset(&x) ) }); } } criterion_group!(benches, bench_metadata); criterion_main!(benches);