kermit_bench/
benchmark.rs1use {super::downloader::DownloadSpec, std::path::Path};
2
3pub struct SubTask {
4 pub name: &'static str,
5 pub description: &'static str,
6 pub data_paths: &'static [&'static str],
7 pub query_paths: &'static [&'static str],
8}
9
10pub struct Task {
11 pub name: &'static str,
12 pub description: &'static str,
13 pub subtasks: &'static [SubTask],
14}
15
16pub struct BenchmarkMetadata {
17 pub name: &'static str,
18 pub description: &'static str,
19 pub download_spec: DownloadSpec,
20 pub tasks: &'static [Task],
21}
22
23pub trait BenchmarkConfig {
24 fn metadata(&self) -> &BenchmarkMetadata;
25 fn load(&self, source: &Path, path: &Path) -> Result<(), Box<dyn std::error::Error>>;
26 fn validate(&self, path: &Path) -> Result<(), Box<dyn std::error::Error>> {
27 let metadata = self.metadata();
28
29 for task in metadata.tasks {
30 for subtask in task.subtasks {
31 for data_path in subtask.data_paths {
33 let full_data_path = path.join(metadata.download_spec.name).join(data_path);
34 if !full_data_path.exists() {
35 return Err(format!(
36 "Data path does not exist: {} (expected at: {})",
37 data_path,
38 full_data_path.display()
39 )
40 .into());
41 }
42 }
43
44 for query_path in subtask.query_paths {
46 let full_query_path = path.join(metadata.download_spec.name).join(query_path);
47 if !full_query_path.exists() {
48 return Err(format!(
49 "Query path does not exist: {} (expected at: {})",
50 query_path,
51 full_query_path.display()
52 )
53 .into());
54 }
55 }
56 }
57 }
58
59 Ok(())
60 }
61}