mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
use stopwatch for a* timing
This commit is contained in:
parent
26264bf576
commit
138f683776
1 changed files with 4 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MLEM.Pathfinding {
|
||||
|
@ -28,7 +29,7 @@ namespace MLEM.Pathfinding {
|
|||
}
|
||||
|
||||
public Stack<T> FindPath(T start, T goal, GetCost costFunction = null, float? defaultCost = null, int? maxTries = null, bool? allowDiagonals = null) {
|
||||
var startTime = DateTime.UtcNow;
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
|
||||
var getCost = costFunction ?? this.DefaultCostFunction;
|
||||
var diags = allowDiagonals ?? this.DefaultAllowDiagonals;
|
||||
|
@ -86,8 +87,9 @@ namespace MLEM.Pathfinding {
|
|||
break;
|
||||
}
|
||||
|
||||
stopwatch.Stop();
|
||||
this.LastTriesNeeded = count;
|
||||
this.LastTimeNeeded = DateTime.UtcNow - startTime;
|
||||
this.LastTimeNeeded = stopwatch.Elapsed;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue