Skip to main content

kermit_bench/
lib.rs

1//! Benchmark infrastructure for Kermit.
2//!
3//! Provides dataset download, conversion (to Parquet), and benchmark
4//! task/subtask definitions. The
5//! [`BenchmarkManager`](manager::BenchmarkManager) coordinates downloading and
6//! loading benchmark datasets, while
7//! [`BenchmarkConfig`](benchmark::BenchmarkConfig) defines the interface each
8//! benchmark must implement.
9
10pub mod benchmark;
11pub mod benchmarks;
12pub mod downloader;
13pub mod generation;
14pub mod manager;
15mod utils;
16
17#[cfg(test)]
18mod tests {
19    use {
20        crate::{benchmarks::Benchmark, manager::BenchmarkManager},
21        std::path::PathBuf,
22    };
23
24    #[test]
25    fn oxford_benchmark() {
26        let tmp_dir = PathBuf::from("data"); // env::temp_dir().join("kermit-bench-testing");
27        if tmp_dir.exists() {
28            std::fs::remove_dir_all(&tmp_dir).expect("Failed to remove temporary directory");
29        }
30        std::fs::create_dir_all(&tmp_dir).expect("Failed to create temporary directory");
31        let mut man = BenchmarkManager::new(&tmp_dir);
32        assert!(man.add_benchmark(Benchmark::Oxford).is_ok());
33
34        let ds_dir = tmp_dir.join(Benchmark::Oxford.config().metadata().download_spec.name);
35        assert!(ds_dir.exists());
36
37        // Test validation - should succeed when dataset is properly loaded
38        assert!(Benchmark::Oxford.config().validate(&tmp_dir).is_ok());
39
40        assert!(man.rm_benchmark(Benchmark::Oxford).is_ok());
41    }
42}