public void PerformanceSummary_HasInfo()
        {
            var solver = new PathSolver <Point, PathTestOption>(_testMap);

            solver.BuildAdjacencyGraph(new Point[] { _startPt, _reachableEndPt, _unreachableEndPt });
            var solution = solver.FindPath(_startPt, _reachableEndPt, PathTestOption.Normal);

            var summary = solver.PerformanceSummary();

            Assert.IsNotNull(summary);
            StringAssert.Contains(summary, "pathCount=1;");
        }
Example #2
0
        /// <summary>
        /// Search for a whole lot of paths using a large map.
        /// </summary>
        private static void Benchmark()
        {
            // Build the necessary pieces (as above in Demo()).
            var map       = new Map(_benchmarkMapStrings);
            var tileGraph = new TileGraph(map);
            var solver    = new PathSolver <Point2D, int>(tileGraph);

            // Init the solver's graph.  (This step is included in solver.LifetimeSolutionTimeMS, by the way.)
            solver.BuildAdjacencyGraph(_benchmarkPts);

            // Solve a path for every combination of 1 starting point and 2 destination points.  (So if P is the number of
            // points, then we're solving P*(P-1)*(P-2)/2 paths.)
            for (var startIdx = 0; startIdx < _benchmarkPts.Length; ++startIdx)
            {
                var startPt = _benchmarkPts[startIdx];
                for (var endIdx1 = 0; endIdx1 < _benchmarkPts.Length; ++endIdx1)
                {
                    if (endIdx1 == startIdx)
                    {
                        continue;
                    }

                    for (var endIdx2 = endIdx1 + 1; endIdx2 < _benchmarkPts.Length; ++endIdx2)
                    {
                        if (endIdx2 == startIdx)
                        {
                            continue;
                        }

                        var endPts     = new[] { _benchmarkPts[endIdx1], _benchmarkPts[endIdx2] };
                        var pathResult = solver.FindPath(startPt, endPts, 0);
                    }
                }
            }

            // Write out a summary of the PathSolver's lifetime statistics.
            Console.WriteLine(solver.PerformanceSummary());
        }