Skip to content

Commit ef546b9

Browse files
committed
mod: show precise path length in benchmark
1 parent 6c8da6b commit ef546b9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

benchmark/benchmark.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,16 @@ function benchmark(opt) {
4040
var fields = [
4141
opt.header,
4242
(''+result.time + 'ms').yellow,
43-
'length' , result.returnValue.length,
43+
'length' , formatFloat(PF.Util.pathLength(result.returnValue)),
4444
opt.footer,
4545
];
4646
console.log(fields.join(' '));
4747
}
4848

49+
function formatFloat(float) {
50+
return Math.round(float * 1000) / 1000;
51+
}
52+
4953
function map2grid(map) {
5054
return new PF.Grid(map.width, map.height, map.grid);
5155
}
@@ -63,7 +67,7 @@ testCases.forEach(function(test) {
6367

6468
var result = benchmark({
6569
header: 'AStarFinder',
66-
finder: new PF.AStarFinder,
70+
finder: new PF.AStarFinder({allowDiagonal: true}),
6771
grid: grid,
6872
startX: scen.startX,
6973
startY: scen.startY,

0 commit comments

Comments
 (0)