feat(bench): move benching to actual benches, primitively
cargo devel CI / cargo CI (push) Successful in 6m12s Details

This commit is contained in:
Christoph J. Scherr 2024-08-07 22:10:17 +02:00
parent 7644970d1f
commit c7b068ef31
3 changed files with 45 additions and 0 deletions

View File

@ -64,3 +64,11 @@ test-log = { version = "0.2.16", default-features = false, features = [
"color", "color",
"trace", "trace",
] } ] }
[[bench]]
name = "solver_naive"
harness = false
[[bench]]
name = "solver_stupid"
harness = false

18
benches/solver_naive.rs Normal file
View File

@ -0,0 +1,18 @@
use wordle_analyzer::bench::builtin::BuiltinBenchmark;
use wordle_analyzer::bench::Benchmark;
use wordle_analyzer::game::{self, GameBuilder};
use wordle_analyzer::solve::{NaiveSolver, Solver};
use wordle_analyzer::wlist::builtin::BuiltinWList;
fn main() -> anyhow::Result<()> {
let wl = BuiltinWList::english(5);
let builder: GameBuilder<'_, BuiltinWList> = game::Game::builder(&wl)
.length(5)
.max_steps(6)
.precompute(true);
let solver: NaiveSolver<_> = NaiveSolver::build(&wl)?;
let bench = BuiltinBenchmark::build(&wl, solver, builder, 16)?;
bench.start(2000, &bench.builder())?;
println!("{}", bench.report());
Ok(())
}

19
benches/solver_stupid.rs Normal file
View File

@ -0,0 +1,19 @@
use wordle_analyzer::bench::builtin::BuiltinBenchmark;
use wordle_analyzer::bench::Benchmark;
use wordle_analyzer::game::{self, GameBuilder};
use wordle_analyzer::solve::Solver;
use wordle_analyzer::solve::StupidSolver;
use wordle_analyzer::wlist::builtin::BuiltinWList;
fn main() -> anyhow::Result<()> {
let wl = BuiltinWList::english(5);
let builder: GameBuilder<'_, BuiltinWList> = game::Game::builder(&wl)
.length(5)
.max_steps(6)
.precompute(true);
let solver: StupidSolver<_> = StupidSolver::build(&wl)?;
let bench = BuiltinBenchmark::build(&wl, solver, builder, 16)?;
bench.start(2000, &bench.builder())?;
println!("{}", bench.report());
Ok(())
}