diff options
author | Daniel Schadt <kingdread@gmx.de> | 2021-11-19 20:49:47 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2021-11-19 20:49:47 +0100 |
commit | b614f8e4798b2c6bbdbdd86e8ec27d5352df8c44 (patch) | |
tree | fa3d76535e0931dbe5c82872a93d04d9b6065e0a /benches | |
parent | 287c21cea382b6dfcce6d76a677ce3c8434e50b4 (diff) | |
parent | 24187066c136a01a9cb688e371ca748e36331e58 (diff) | |
download | evtclib-b614f8e4798b2c6bbdbdd86e8ec27d5352df8c44.tar.gz evtclib-b614f8e4798b2c6bbdbdd86e8ec27d5352df8c44.tar.bz2 evtclib-b614f8e4798b2c6bbdbdd86e8ec27d5352df8c44.zip |
Merge branch 'more-benches'
Diffstat (limited to 'benches')
-rw-r--r-- | benches/analyzers.rs | 65 | ||||
-rw-r--r-- | benches/parsing_benchmark.rs | 20 |
2 files changed, 80 insertions, 5 deletions
diff --git a/benches/analyzers.rs b/benches/analyzers.rs new file mode 100644 index 0000000..ee25253 --- /dev/null +++ b/benches/analyzers.rs @@ -0,0 +1,65 @@ +use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput}; +use evtclib::Compression; + +macro_rules! analyzer_benchmark { + ($fname:ident, $boss:expr, $log:expr) => { + fn $fname(c: &mut Criterion) { + let log = evtclib::process_file($log, Compression::Zip).unwrap(); + let analyzer = log.analyzer().unwrap(); + + let mut group = c.benchmark_group(&format!("analyzers/{}", $boss)); + group.throughput(Throughput::Elements(1)); + + group.bench_function("is_cm", |b| { + b.iter(|| { + black_box(analyzer.is_cm()); + }) + }); + + group.bench_function("outcome", |b| { + b.iter(|| { + black_box(analyzer.outcome()); + }) + }); + group.finish(); + } + }; +} + +macro_rules! benchmarks { + ($(($fname:ident, $boss:expr, $log:expr),)*) => { + $(analyzer_benchmark!($fname, $boss, $log);)* + + criterion_group! { + name = benches; + config = Criterion::default(); + targets = $($fname,)* + } + + criterion_main!(benches); + } +} + +benchmarks! { + (raid_generic, "generic-raid", "tests/logs/vg-20200421.zevtc"), + (raid_xera, "xera", "tests/logs/xera-20200415.zevtc"), + (raid_cairn, "cairn", "tests/logs/cairn-20200426.zevtc"), + (raid_mo, "mo", "tests/logs/mo-20200426.zevtc"), + (raid_samarog, "samarog", "tests/logs/samarog-20200426.zevtc"), + (raid_deimos, "deimos", "tests/logs/deimos-20200428.zevtc"), + (raid_sh, "sh", "tests/logs/desmina-20200425.zevtc"), + (raid_river, "river", "tests/logs/river-20210412.zevtc"), + (raid_dhuum, "dhuum", "tests/logs/dhuum-20200428.zevtc"), + (raid_ca, "ca", "tests/logs/ca-20200426.zevtc"), + (raid_largos, "largos", "tests/logs/largos-20200426.zevtc"), + (raid_qadim, "qadim", "tests/logs/qadim-20200427.zevtc"), + (raid_adina, "adina", "tests/logs/adina-20200427.zevtc"), + (raid_sabir, "sabir", "tests/logs/sabir-20200427.zevtc"), + (raid_qadimp, "qadimp", "tests/logs/qadimp-20200427.zevtc"), + + (fractal_generic, "generic-fractal", "tests/logs/ensolyss-20200427.zevtc"), + (fractal_ai, "ai", "tests/logs/ai-20200922.zevtc"), + (fractal_skorvald, "skorvald", "tests/logs/skorvald-20200920.zevtc"), + + (strike_generic, "generic-strike", "tests/logs/whisper-20200424.zevtc"), +} diff --git a/benches/parsing_benchmark.rs b/benches/parsing_benchmark.rs index 1e81e3c..4174cab 100644 --- a/benches/parsing_benchmark.rs +++ b/benches/parsing_benchmark.rs @@ -1,4 +1,4 @@ -use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput}; use std::{fs, io, io::Read}; use zip::ZipArchive; @@ -11,7 +11,11 @@ const QADIM_LOG: &str = "tests/logs/qadim-20200427.zevtc"; /// (such as a buffered reader or a memory mapped file) so that the downstream application will /// receive the log fast. fn zipped_qadim_benchmark(c: &mut Criterion) { - c.bench_function("on-disk zipped Qadim", |b| { + let file_size = fs::metadata(QADIM_LOG).unwrap().len(); + let mut group = c.benchmark_group("parsing/qadim/zipped"); + + group.throughput(Throughput::Bytes(file_size)); + group.bench_function("disk", |b| { b.iter(|| evtclib::process_file(black_box(QADIM_LOG), evtclib::Compression::Zip).unwrap()) }); } @@ -24,8 +28,11 @@ fn zipped_qadim_benchmark(c: &mut Criterion) { /// have to de-compress logs at some point. fn zipped_qadim_ram_benchmark(c: &mut Criterion) { let log_data = &fs::read(QADIM_LOG).unwrap(); + let file_size = log_data.len(); + let mut group = c.benchmark_group("parsing/qadim/zipped"); - c.bench_function("in-memory zipped Qadim", |b| { + group.throughput(Throughput::Bytes(file_size as u64)); + group.bench_function("memory", |b| { b.iter(|| { evtclib::process_stream(io::Cursor::new(log_data), evtclib::Compression::Zip).unwrap() }) @@ -48,7 +55,10 @@ fn unzipped_qadim_benchmark(c: &mut Criterion) { .unwrap(); let log_data = &log_data; - c.bench_function("in-memory unzipped Qadim", |b| { + let mut group = c.benchmark_group("parsing/qadim/unzipped"); + + group.throughput(Throughput::Bytes(log_data.len() as u64)); + group.bench_function("memory", |b| { b.iter(|| { evtclib::process_stream(io::Cursor::new(log_data), evtclib::Compression::None).unwrap() }) @@ -66,7 +76,7 @@ fn process_qadim(c: &mut Criterion) { let file = io::BufReader::new(fs::File::open(QADIM_LOG).unwrap()); let raw_evtc = evtclib::raw::parse_zip(file).unwrap(); - c.bench_function("process Qadim", |b| { + c.bench_function("process/qadim", |b| { b.iter(|| evtclib::process(&raw_evtc).unwrap()) }); } |