-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The worst case AI update time is where a new game with an empty board must be evaluated. See issue #5.
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#[macro_use] | ||
extern crate criterion; | ||
|
||
use criterion::Criterion; | ||
|
||
use open_ttt_lib::ai; | ||
use open_ttt_lib::game; | ||
|
||
fn flawless_ai_moves_benchmarks(c: &mut Criterion) { | ||
let game = game::Game::new(); | ||
let mistake_probability = 0.0; | ||
let ai_opponent = ai::Opponent::new(mistake_probability); | ||
|
||
c.bench_function("New game with flawless AI", |b| { | ||
b.iter(|| ai_opponent.get_move(&game)) | ||
}); | ||
} | ||
|
||
fn build_benchmark_configuration() -> Criterion { | ||
// At the moment the AI takes a LONG time to update so reduce | ||
// the sample size so the test completes in this decade. | ||
Criterion::default().sample_size(10) | ||
} | ||
|
||
criterion_group!( | ||
name = benches; | ||
config = build_benchmark_configuration(); | ||
targets = flawless_ai_moves_benchmarks); | ||
|
||
criterion_main!(benches); |