private void DoBenchmark() { Log("==== Benchmark Started ===="); Random rnd = new Random(); int[] pointNums = { 100, 200, 500 }; int benchNum = (int)numBenchMark.Value; foreach (var pointNum in pointNums) { this.Log(string.Format("== PointNum : {0}", pointNum)); for (int benchIndex = 0; benchIndex < benchNum; benchIndex++) { GeneratePoints(pointNum, rnd); CalcDistTable(); long t0 = Stopwatch.GetTimestamp(); SortNearestNeighbor(); double ms0 = (Stopwatch.GetTimestamp() - t0) / (double)Stopwatch.Frequency * 1000; float calcDist0 = CalcRouteDist(this.visitOrder); this.pbxDraw.Invalidate(); t0 = Stopwatch.GetTimestamp(); SortNearestNeighbor(); AlgDll.Improve2Opt(this.visitOrder, this.visitOrder.Length, this.distTable); double ms1 = (Stopwatch.GetTimestamp() - t0) / (double)Stopwatch.Frequency * 1000; float calcDist1 = CalcRouteDist(this.visitOrder); this.pbxDraw.Invalidate(); t0 = Stopwatch.GetTimestamp(); this.visitOrder = TspCities.Run(this.distTable, this.points.Length, 1, 0, (RoutingSearchParameters)this.grdPrm.SelectedObject); double ms2 = (Stopwatch.GetTimestamp() - t0) / (double)Stopwatch.Frequency * 1000; float calcDist2 = CalcRouteDist(this.visitOrder); this.pbxDraw.Invalidate(); this.Log(string.Format("Greedy : {0}, Time : {1}ms / Greedy+2OPT : {2}, Time : {3}ms / GoogleRoute : {4}, Time : {5}ms", calcDist0, ms0, calcDist1, ms1, calcDist2, ms2)); } } Log("==== Benchmark Finished ===="); }
private void SortGoogleRoute(RoutingSearchParameters srcPrms) { this.visitOrder = TspCities.Run(this.distTable, this.points.Length, 1, 0, srcPrms); }