kermit_bench/
benchmark.rs1use {super::downloader::DownloadSpec, std::path::Path};
2
3pub struct SubTask {
6 pub name: &'static str,
7 pub description: &'static str,
8 pub data_paths: &'static [&'static str],
9 pub query_paths: &'static [&'static str],
10}
11
12pub struct Task {
15 pub name: &'static str,
16 pub description: &'static str,
17 pub subtasks: &'static [SubTask],
18}
19
20pub struct BenchmarkMetadata {
23 pub name: &'static str,
24 pub description: &'static str,
25 pub download_spec: DownloadSpec,
26 pub tasks: &'static [Task],
27}
28
29pub trait BenchmarkConfig {
32 fn metadata(&self) -> &BenchmarkMetadata;
34
35 fn load(&self, source: &Path, path: &Path) -> Result<(), Box<dyn std::error::Error>>;
38 fn validate(&self, path: &Path) -> Result<(), Box<dyn std::error::Error>> {
41 let metadata = self.metadata();
42
43 for task in metadata.tasks {
44 for subtask in task.subtasks {
45 for data_path in subtask.data_paths {
47 let full_data_path = path.join(metadata.download_spec.name).join(data_path);
48 if !full_data_path.exists() {
49 return Err(format!(
50 "Data path does not exist: {} (expected at: {})",
51 data_path,
52 full_data_path.display()
53 )
54 .into());
55 }
56 }
57
58 for query_path in subtask.query_paths {
60 let full_query_path = path.join(metadata.download_spec.name).join(query_path);
61 if !full_query_path.exists() {
62 return Err(format!(
63 "Query path does not exist: {} (expected at: {})",
64 query_path,
65 full_query_path.display()
66 )
67 .into());
68 }
69 }
70 }
71 }
72
73 Ok(())
74 }
75}