-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathengine_benches.rs
78 lines (66 loc) · 2.25 KB
/
engine_benches.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
use arimaa_engine_step::{take_actions, GameState};
use criterion::{black_box, criterion_group, criterion_main, Bencher, Criterion};
fn bench_valid_actions(b: &mut Bencher) {
let game_state: GameState = "
1g
+-----------------+
8| h c d m r d c h |
7| r r r e r r r |
6| x x |
5| |
4| r C |
3| x x |
2| R R R R E R R R |
1| H D M R D C H |
+-----------------+
a b c d e f g h
"
.parse()
.unwrap();
let game_state = black_box(game_state);
b.iter(|| {
let game_state = game_state.clone();
let game_state = take_actions!(game_state => b4n);
let valid_actions = game_state.valid_actions();
if valid_actions.is_empty() {
panic!();
}
let game_state = take_actions!(game_state => a4e);
let valid_actions = game_state.valid_actions();
if valid_actions.is_empty() {
panic!();
}
let game_state = take_actions!(game_state => b2n);
let valid_actions = game_state.valid_actions();
if valid_actions.is_empty() {
panic!();
}
let game_state = take_actions!(game_state => f2n);
let valid_actions = game_state.valid_actions();
if valid_actions.is_empty() {
panic!();
}
let game_state = take_actions!(game_state => d7s);
let valid_actions = game_state.valid_actions();
if valid_actions.is_empty() {
panic!();
}
let game_state = take_actions!(game_state => e7s);
let valid_actions = game_state.valid_actions();
if valid_actions.is_empty() {
panic!();
}
let game_state = take_actions!(game_state => f7s);
let valid_actions = game_state.valid_actions();
if valid_actions.is_empty() {
panic!();
}
let game_state = take_actions!(game_state => g7s);
game_state.valid_actions()
});
}
fn bench_main(c: &mut Criterion) {
c.bench_function("valid_actions", bench_valid_actions);
}
criterion_group!(benches, bench_main);
criterion_main!(benches);