Skip to content

Commit 471a0fd

Browse files
committed
fix(benches): reinstate regular benches for DFS
1 parent c21c97e commit 471a0fd

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

benches/algos-fill.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,23 @@ impl Pt {
2727
}
2828

2929
#[inline]
30-
fn successors_limit(pt: &Pt, size: u16) -> Vec<Pt> {
30+
fn successors(pt: &Pt) -> Vec<Pt> {
3131
let mut ret = Vec::with_capacity(4);
3232
if 0 < pt.x {
3333
ret.push(Pt::new(pt.x - 1, pt.y));
3434
}
35-
if pt.x < size {
35+
if pt.x < 32 {
3636
ret.push(Pt::new(pt.x + 1, pt.y));
3737
}
3838
if 0 < pt.y {
3939
ret.push(Pt::new(pt.x, pt.y - 1));
4040
}
41-
if pt.y < size {
41+
if pt.y < 32 {
4242
ret.push(Pt::new(pt.x, pt.y + 1));
4343
}
4444
ret
4545
}
4646

47-
#[inline]
48-
fn successors(pt: &Pt) -> Vec<Pt> {
49-
successors_limit(pt, 32)
50-
}
51-
5247
fn corner_to_corner_astar(c: &mut Criterion) {
5348
c.bench_function("fill-corner_to_corner_astar", |b| {
5449
b.iter(|| {
@@ -167,13 +162,11 @@ fn no_path_bfs(c: &mut Criterion) {
167162
});
168163
}
169164

170-
// We have to restrict the grid to a very small one, as the resources
171-
// needed to run dfs over all the path combination augment very quickly.
172-
fn no_path_dfs_restricted(c: &mut Criterion) {
165+
fn no_path_dfs(c: &mut Criterion) {
173166
c.bench_function("fill-no_path_dfs", |b| {
174167
b.iter(|| {
175168
assert_eq!(
176-
dfs(Pt::new(2, 3), |p| successors_limit(p, 4), |_| false),
169+
dfs(Pt::new(2, 3), successors, |_| false),
177170
None
178171
)
179172
});
@@ -225,7 +218,7 @@ criterion_group!(
225218
corner_to_corner_iddfs,
226219
no_path_astar,
227220
no_path_bfs,
228-
no_path_dfs_restricted,
221+
no_path_dfs,
229222
no_path_dijkstra,
230223
no_path_fringe,
231224
);

0 commit comments

Comments
 (0)