-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds '--compare-solvers' option #882
Conversation
ef24e06
to
08e87e1
Compare
crates/spk-solve/src/io.rs
Outdated
let mut lines = Vec::new(); | ||
let mut max_width = 0; | ||
for (solver_kind, duration, solver, result) in solver_results.iter() { | ||
let solved = if result.is_ok() { "solved" } else { "failed" }; | ||
let seconds = duration.as_secs_f64(); | ||
let total_builds = solver.get_total_builds(); | ||
let num_steps = solver.get_number_of_steps(); | ||
let num_steps_back = solver.get_number_of_steps_back(); | ||
|
||
let kind = format!("{solver_kind}"); | ||
let length = kind.len(); | ||
max_width = max(max_width, length); | ||
|
||
lines.push(( | ||
kind, | ||
solved, | ||
seconds, | ||
num_steps, | ||
num_steps_back, | ||
total_builds, | ||
)); | ||
} | ||
|
||
for (solver_kind, solved, seconds, num_steps, num_steps_back, total_builds) in | ||
lines.into_iter() | ||
{ | ||
let padding = " ".repeat(max_width - solver_kind.len()); | ||
let builds = "build".pluralize(total_builds); | ||
let steps = "step".pluralize(num_steps); | ||
|
||
println!("{solver_kind}{padding}: {solved} in {seconds:.6} seconds, {num_steps} {steps} ({num_steps_back} back), {total_builds} {builds} at {:.3} builds/sec", total_builds as f64 / seconds); | ||
} | ||
|
||
// Give the first result to finish back to the rest of the | ||
// program as the result. | ||
match solver_results.first() { | ||
Some((_, _, _, result)) => match result { | ||
Ok(s) => Ok(s.clone()), | ||
Err(e) => Err(Error::String(format!("{e}"))), | ||
}, | ||
None => Err(Error::String( | ||
"Multi-solver task failed to run any tasks for comparsion.".to_string(), | ||
)), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be captured in a separate function easily, I think it would go a long way to clarifying and keeping the the complexity of this outer function down as much as possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pulled this out into a method, and added a struct for the solver result data.
…compare the work they did. Signed-off-by: David Gilligan-Cook <dcook@imageworks.com>
Signed-off-by: David Gilligan-Cook <dcook@imageworks.com>
08e87e1
to
f1a11d6
Compare
This adds the
--compare-solvers
option that will run all the solvers to completion and produce a short report comparing the work they did. The report is fairly basic at the moment, but it is useful when comparing solvers with different settings or tweaks. The first solver to finish is used as 'the result' to return the rest of the program.In cases where one solver might run for a long time before finishing, the existing
--timeout <seconds>
option can be used to limit the solvers run time.Examples: