-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathmod.rs
More file actions
66 lines (57 loc) · 1.86 KB
/
mod.rs
File metadata and controls
66 lines (57 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use std::fmt::Display;
use crate::prelude::*;
use super::{RunnerMode, config::Config};
mod executor;
mod helpers;
mod interfaces;
#[cfg(test)]
mod tests;
mod valgrind;
mod wall_time;
use executor::Executor;
use helpers::profile_folder::create_profile_folder;
pub use interfaces::{ExecutorName, RunData};
use valgrind::executor::ValgrindExecutor;
use wall_time::executor::WallTimeExecutor;
impl Display for RunnerMode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
RunnerMode::Instrumentation => write!(f, "instrumentation"),
RunnerMode::Walltime => write!(f, "walltime"),
}
}
}
pub const EXECUTOR_TARGET: &str = "executor";
pub fn get_executor_from_mode(mode: &RunnerMode) -> Box<dyn Executor> {
match mode {
RunnerMode::Instrumentation => {
// Valgrind/Callgrind is not available on macOS (notably arm64 macOS).
// If the user requested Instrumentation mode on macOS, fall back to
// the WallTime executor so the produced archive and upload metadata
// accurately reflect what was collected (no Callgrind profiles).
#[cfg(target_os = "macos")]
{
Box::new(WallTimeExecutor::new())
}
#[cfg(not(target_os = "macos"))]
{
Box::new(ValgrindExecutor)
}
}
RunnerMode::Walltime => Box::new(WallTimeExecutor::new()),
}
}
pub fn get_all_executors() -> Vec<Box<dyn Executor>> {
vec![
Box::new(ValgrindExecutor),
Box::new(WallTimeExecutor::new()),
]
}
pub fn get_run_data(config: &Config) -> Result<RunData> {
let profile_folder = if let Some(profile_folder) = &config.profile_folder {
profile_folder.clone()
} else {
create_profile_folder()?
};
Ok(RunData { profile_folder })
}