feat(gpodder_sqlite): added benchmarking support
This commit is contained in:
parent
73988d6264
commit
d329a0e61c
4 changed files with 335 additions and 1 deletions
28
gpodder_sqlite/benches/devices.rs
Normal file
28
gpodder_sqlite/benches/devices.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
mod common;
|
||||
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use gpodder::{DevicePatch, DeviceRepository};
|
||||
|
||||
pub fn bench_devices_for_user(c: &mut Criterion) {
|
||||
let (store, users) = common::setup();
|
||||
|
||||
for i in 0..100000 {
|
||||
store
|
||||
.update_device_info(
|
||||
&users[i % users.len()],
|
||||
&format!("device id {i}"),
|
||||
DevicePatch {
|
||||
caption: Some(format!("device caption {i}")),
|
||||
r#type: None,
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
c.bench_function("devices for user", |b| {
|
||||
b.iter(|| store.devices_for_user(&users[0]).unwrap())
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(devices, bench_devices_for_user);
|
||||
criterion_main!(devices);
|
||||
Loading…
Add table
Add a link
Reference in a new issue