use criterion::{black_box, criterion_group, criterion_main, Criterion};
use digital_gpu::{GpuHandle, GpuSpec, CompressionMode};
fn bench_curve_sample(c: &mut Criterion) {
let gpu = GpuHandle::boot(GpuSpec::new().effective_gb(64))
.expect("boot");
c.bench_function("curve_sample_32gb_100pts", |b| {
b.iter(|| {
gpu.curve_sample(
black_box(32 * 1024 * 1024 * 1024),
black_box(100),
)
});
});
}
fn bench_bandwidth_query(c: &mut Criterion) {
let gpu = GpuHandle::boot(GpuSpec::new().effective_gb(64))
.expect("boot");
c.bench_function("bandwidth_at_1gb", |b| {
b.iter(|| {
gpu.bandwidth_at_effective(black_box(1024 * 1024 * 1024))
});
});
}
fn bench_compression_alloc(c: &mut Criterion) {
let gpu = GpuHandle::boot(GpuSpec::new()
.physical_gb(6)
.effective_gb(192)) .expect("boot");
c.bench_function("allocate_4gb_via_32x_compression", |b| {
b.iter(|| {
if let Some(arena) = gpu.compressed_arena() {
let _ = black_box(arena.allocate_effective(4 * 1024 * 1024 * 1024));
}
});
});
}
fn bench_boot(c: &mut Criterion) {
c.bench_function("boot_8gb_digital_gpu", |b| {
b.iter(|| {
let _ = GpuHandle::boot(GpuSpec::new().effective_gb(8));
});
});
}
criterion_group!(
benches,
bench_curve_sample,
bench_bandwidth_query,
bench_compression_alloc,
bench_boot
);
criterion_main!(benches);