Exemplo n.º 1
0
        public static BenchmarkResult <TK, TD> BenchmarkFirstOnly <TK, TD>(
            CspSolver <TK, TD> cspSolver, CspProblem <TK, TD> problem)
        {
            var stopWatch = new Stopwatch();

            problem.ClearAll();

            stopWatch.Start();
            var first = cspSolver.FindSolutions(problem).First();

            stopWatch.Stop();

            var firstNodesVisited = cspSolver.NodesVisited;
            var firstSolutionTime = stopWatch.ElapsedMilliseconds;

            problem.ClearAll();

            return(new BenchmarkResult <TK, TD>(
                       firstSolutionTime,
                       firstNodesVisited,
                       null,
                       null,
                       null,
                       first));
        }
Exemplo n.º 2
0
        public static BenchmarkResult <TK, TD> BenchmarkAll <TK, TD>(
            CspSolver <TK, TD> cspSolver, CspProblem <TK, TD> problem)
        {
            var stopWatch = new Stopwatch();

            problem.ClearAll();

            stopWatch.Restart();
            _ = cspSolver.FindSolutions(problem).Last();
            stopWatch.Stop();

            problem.ClearAll();

            return(new BenchmarkResult <TK, TD>(
                       null,
                       null,
                       stopWatch.ElapsedMilliseconds,
                       cspSolver.NodesVisited,
                       cspSolver.SolutionCount,
                       null));
        }