improve xtask
This commit is contained in:
@ -239,6 +239,8 @@ fn regression() -> Result<(), DynError> {
|
|||||||
let res = try_regression();
|
let res = try_regression();
|
||||||
|
|
||||||
snake.kill().and(prod.kill())?;
|
snake.kill().and(prod.kill())?;
|
||||||
|
stop_local_docker()?;
|
||||||
|
stop_production()?;
|
||||||
let (won, draw, loose) = res?;
|
let (won, draw, loose) = res?;
|
||||||
let games = won + draw + loose;
|
let games = won + draw + loose;
|
||||||
println!(
|
println!(
|
||||||
@ -265,7 +267,7 @@ fn try_regression() -> Result<(usize, usize, usize), DynError> {
|
|||||||
const GAMES: usize = 100;
|
const GAMES: usize = 100;
|
||||||
// limit the parallelism
|
// limit the parallelism
|
||||||
rayon::ThreadPoolBuilder::new()
|
rayon::ThreadPoolBuilder::new()
|
||||||
.num_threads(std::thread::available_parallelism()?.get() / 8)
|
.num_threads(std::thread::available_parallelism()?.get() / 4)
|
||||||
.build_global()
|
.build_global()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -401,6 +403,13 @@ fn run_local_docker(port: u16) -> Result<Child, DynError> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn stop_local_docker() -> Result<(), DynError> {
|
||||||
|
Command::new("docker")
|
||||||
|
.args(["stop", "battlesnake-regression-local"])
|
||||||
|
.status()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn run_production(port: u16) -> Result<Child, DynError> {
|
fn run_production(port: u16) -> Result<Child, DynError> {
|
||||||
let mut snake = Command::new("docker")
|
let mut snake = Command::new("docker")
|
||||||
.args([
|
.args([
|
||||||
@ -431,6 +440,13 @@ fn run_production(port: u16) -> Result<Child, DynError> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn stop_production() -> Result<(), DynError> {
|
||||||
|
Command::new("docker")
|
||||||
|
.args(["stop", "battlesnake-regression-production"])
|
||||||
|
.status()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn docker() -> Result<(), DynError> {
|
fn docker() -> Result<(), DynError> {
|
||||||
if !Command::new("docker")
|
if !Command::new("docker")
|
||||||
.current_dir(project_root())
|
.current_dir(project_root())
|
||||||
|
Reference in New Issue
Block a user