public static void PrintResults() { TimeSpan timeSpan = DateTime.UtcNow - AstarProfiler.startTime; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("============================\n\t\t\t\tProfile results:\n============================\n"); int num = 5; foreach (KeyValuePair <string, AstarProfiler.ProfilePoint> current in AstarProfiler.profiles) { num = Math.Max(current.Key.Length, num); } stringBuilder.Append(" Name ".PadRight(num)).Append("|").Append(" Total Time\t".PadRight(20)).Append("|").Append(" Total Calls ".PadRight(20)).Append("|").Append(" Avg/Call ".PadRight(20)); foreach (KeyValuePair <string, AstarProfiler.ProfilePoint> current2 in AstarProfiler.profiles) { double totalMilliseconds = current2.Value.watch.Elapsed.TotalMilliseconds; int totalCalls = current2.Value.totalCalls; if (totalCalls >= 1) { string key = current2.Key; stringBuilder.Append("\n").Append(key.PadRight(num)).Append("| "); stringBuilder.Append(totalMilliseconds.ToString("0.0").PadRight(20)).Append("| "); stringBuilder.Append(totalCalls.ToString().PadRight(20)).Append("| "); stringBuilder.Append((totalMilliseconds / (double)totalCalls).ToString("0.000").PadRight(20)); stringBuilder.Append(AstarMath.FormatBytesBinary((int)current2.Value.totalBytes).PadLeft(10)); } } stringBuilder.Append("\n\n============================\n\t\tTotal runtime: "); stringBuilder.Append(timeSpan.TotalSeconds.ToString("F3")); stringBuilder.Append(" seconds\n============================"); Debug.Log(stringBuilder.ToString()); }
public static void PrintResults() { TimeSpan span = (TimeSpan)(DateTime.UtcNow - startTime); StringBuilder builder = new StringBuilder(); builder.Append("============================\n\t\t\t\tProfile results:\n============================\n"); int num = 5; foreach (KeyValuePair <string, ProfilePoint> pair in profiles) { num = Math.Max(pair.Key.Length, num); } builder.Append(" Name ".PadRight(num)).Append("|").Append(" Total Time\t".PadRight(20)).Append("|").Append(" Total Calls ".PadRight(20)).Append("|").Append(" Avg/Call ".PadRight(20)); foreach (KeyValuePair <string, ProfilePoint> pair2 in profiles) { double totalMilliseconds = pair2.Value.watch.Elapsed.TotalMilliseconds; int totalCalls = pair2.Value.totalCalls; if (totalCalls >= 1) { string key = pair2.Key; builder.Append("\n").Append(key.PadRight(num)).Append("| "); builder.Append(totalMilliseconds.ToString("0.0").PadRight(20)).Append("| "); builder.Append(totalCalls.ToString().PadRight(20)).Append("| "); double num4 = totalMilliseconds / ((double)totalCalls); builder.Append(num4.ToString("0.000").PadRight(20)); builder.Append(AstarMath.FormatBytesBinary((int)pair2.Value.totalBytes).PadLeft(10)); } } builder.Append("\n\n============================\n\t\tTotal runtime: "); builder.Append(span.TotalSeconds.ToString("F3")); builder.Append(" seconds\n============================"); UnityEngine.Debug.Log(builder.ToString()); }
public static void PrintResults() { TimeSpan endTime = DateTime.UtcNow - startTime; var output = new System.Text.StringBuilder(); output.Append("============================\n\t\t\t\tProfile results:\n============================\n"); int maxLength = 5; foreach (KeyValuePair <string, ProfilePoint> pair in profiles) { maxLength = Math.Max(pair.Key.Length, maxLength); } output.Append(" Name ".PadRight(maxLength)). Append("|").Append(" Total Time ".PadRight(20)). Append("|").Append(" Total Calls ".PadRight(20)). Append("|").Append(" Avg/Call ".PadRight(20)); foreach (var pair in profiles) { double totalTime = pair.Value.watch.Elapsed.TotalMilliseconds; int totalCalls = pair.Value.totalCalls; if (totalCalls < 1) { continue; } string name = pair.Key; output.Append("\n").Append(name.PadRight(maxLength)).Append("| "); output.Append(totalTime.ToString("0.0").PadRight(20)).Append("| "); output.Append(totalCalls.ToString().PadRight(20)).Append("| "); output.Append((totalTime / totalCalls).ToString("0.000").PadRight(20)); output.Append(AstarMath.FormatBytesBinary((int)pair.Value.totalBytes).PadLeft(10)); /*output.Append("\nProfile "); * output.Append(pair.Key); * output.Append(" took "); * output.Append(totalTime.ToString("0")); * output.Append(" ms to complete over "); * output.Append(totalCalls); * output.Append(" iteration"); * if (totalCalls != 1) output.Append("s"); * output.Append(", averaging "); * output.Append((totalTime / totalCalls).ToString("0.0")); * output.Append(" ms per call");*/ } output.Append("\n\n============================\n\t\tTotal runtime: "); output.Append(endTime.TotalSeconds.ToString("F3")); output.Append(" seconds\n============================"); Debug.Log(output.ToString()); }