influxdb/server_benchmarks/benches/snapshot.rs

47 lines
1.3 KiB
Rust
Raw Normal View History

2021-04-22 11:15:32 +00:00
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use entry::test_helpers::lp_to_entries;
2021-04-22 11:15:32 +00:00
use flate2::read::GzDecoder;
use mutable_buffer::chunk::{Chunk, ChunkMetrics};
use std::io::Read;
2021-04-22 11:15:32 +00:00
#[inline]
fn snapshot_chunk(chunk: &Chunk) {
let _ = chunk.snapshot();
}
fn chunk(count: usize) -> Chunk {
// m0 is hard coded into tag_values.lp.gz
let mut chunk = Chunk::new("m0", ChunkMetrics::new_unregistered());
2021-04-22 11:15:32 +00:00
let raw = include_bytes!("../../tests/fixtures/lineproto/tag_values.lp.gz");
let mut gz = GzDecoder::new(&raw[..]);
let mut lp = String::new();
gz.read_to_string(&mut lp).unwrap();
for _ in 0..count {
for entry in lp_to_entries(&lp) {
for write in entry.partition_writes().iter().flatten() {
for batch in write.table_batches() {
chunk.write_table_batch(1, 5, batch).unwrap();
}
2021-04-22 11:15:32 +00:00
}
}
}
chunk
}
pub fn snapshot_mb(c: &mut Criterion) {
let mut group = c.benchmark_group("snapshot_mb");
for count in &[1, 2, 3, 4, 5] {
let chunk = chunk(*count as _);
group.bench_function(BenchmarkId::from_parameter(count), |b| {
b.iter(|| snapshot_chunk(&chunk));
});
}
group.finish();
}
criterion_group!(benches, snapshot_mb);
criterion_main!(benches);