public static void generateTestCzworki(Map.Data.MapData map) { int powtorzenia = 100; map.randomFill(10); long[] elapsedMs1 = new long[powtorzenia]; for (int i = 0; i < powtorzenia; i++) { System.GC.Collect(); ServiceAAuth.tab = null; if (ServiceAAuth.tab == null) { var watch1 = System.Diagnostics.Stopwatch.StartNew(); ServiceAAuth.makeTab(map, false); watch1.Stop(); elapsedMs1[i] = watch1.ElapsedMilliseconds; } } using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"pomiar\pomiary\generateTestCzworki.txt", true)) { file.WriteLine("Generowanie czworki"); foreach (var el in elapsedMs1) { file.WriteLine(el); } } }
public static void FindWayDistTestCzworki(Map.Data.MapData map) { int powtorzenia = 10; map.randomFill(10); for (int j = 1; j < 300; j = j + 50) { Vector2 from = new Vector2(0, 0); Vector2 to = new Vector2(j, j); using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"pomiar\pomiary\FindWayDistTestCzworki.txt", true)) { file.WriteLine("PKTY (0, 0) (" + j + ", " + j + ") odleglosc: " + ServiceA.cost(from, to)); } ServiceAAuth.tab = null; if (ServiceAAuth.tab == null) { ServiceAAuth.makeTab(map, false); } long[] elapsedMs1 = new long[powtorzenia]; long[] elapsedMs5 = new long[powtorzenia]; System.GC.Collect(); for (int i = 0; i < powtorzenia; i++) { map.Table[(int)from.x + 800][(int)from.y + 800] = null; map.Table[(int)to.x + 800][(int)to.y + 800] = null; var watch1 = System.Diagnostics.Stopwatch.StartNew(); ServiceAAuth.FindWay(from, to, map, false); watch1.Stop(); elapsedMs1[i] = watch1.ElapsedMilliseconds; var watch5 = System.Diagnostics.Stopwatch.StartNew(); ServiceA.FindWay(from, to, map, false); watch5.Stop(); elapsedMs5[i] = watch5.ElapsedMilliseconds; } using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"pomiar\pomiary\FindWayDistTestCzworki.txt", true)) { file.WriteLine("A* Auth "); long sum = 0; foreach (var el in elapsedMs1) { sum = sum + el; } file.WriteLine(sum / powtorzenia); sum = 0; file.WriteLine("A*"); foreach (var el in elapsedMs5) { sum = sum + el; } file.WriteLine(sum / powtorzenia); } } }