Lines
100 %
Functions
33.33 %
Branches
use bonsaidb::core::{arc_bytes::serde::Bytes, schema::Collection};
use criterion::{Criterion, Throughput};
use serde::{Deserialize, Serialize};
mod bonsai;
#[cfg(feature = "sqlite")]
mod rusqlite;
#[derive(Serialize, Deserialize, Debug, Collection)]
#[collection(name = "resizable-docs")]
struct ResizableDocument {
data: Bytes,
}
pub fn save_documents(c: &mut Criterion) {
static KB: usize = 1024;
// First set of benchmarks tests inserting documents
let mut group = c.benchmark_group("save_documents");
for size in [KB, 2 * KB, 8 * KB, 32 * KB, KB * KB] {
group.throughput(Throughput::Bytes(size as u64));
let mut data = Vec::with_capacity(size);
data.resize_with(size, || 7u8);
let doc = ResizableDocument {
data: Bytes::from(data),
};
bonsai::save_documents(&mut group, &doc);
rusqlite::save_documents(&mut group, &doc);
group.finish();