use dive_eval::{Counter, RunConfig};
use dive_stdlib::host::RunHost;
use crate::CheckOptions;
#[must_use]
pub fn run_config(opts: &CheckOptions, deadlock: bool) -> RunConfig {
#[allow(clippy::cast_possible_wrap, reason = "Java's long: same bits")]
let fingerprint = dive_value::fp64::POLYS
.get(opts.fp_index)
.copied()
.unwrap_or(0) as i64;
RunConfig {
deadlock,
workers: match opts.profile {
dive_eval::Profile::Tlc => i64::try_from(opts.workers).unwrap_or(i64::MAX),
dive_eval::Profile::Dive => 1,
},
seed: opts.seed,
fingerprint,
install: std::env::current_exe()
.map(|p| p.display().to_string())
.unwrap_or_default(),
}
}
pub fn startup_counters(host: &RunHost) {
for c in [
Counter::Generated,
Counter::Distinct,
Counter::Queue,
Counter::Initial,
] {
host.set_counter(c, Some(0));
}
host.set_counter(Counter::Diameter, Some(1));
}
pub fn search_counters(host: &RunHost) {
for c in [
Counter::Generated,
Counter::Distinct,
Counter::Queue,
Counter::Initial,
Counter::Diameter,
Counter::DurationSecs,
] {
host.set_counter(c, None);
}
}