public static int Main(string[] args) { if (args.Length == 0) { //Taking processme.txt from current directory var pathFile = Path.Combine(Environment.CurrentDirectory, "processme.txt"); if (!File.Exists(pathFile)) { var pathDll = Assembly.GetEntryAssembly().Location; var path = Path.GetDirectoryName(pathDll); pathFile = Path.Combine(path, "processme.txt"); } Console.WriteLine($"no arguments name file, taking default processme.txt file from on {pathFile}"); args = new string[] { pathFile }; } var ret = CommandLineApplication.Execute <Program>(args); var table = new ConsoleTable("Class", "Method(Line)", "NumberHit", "TotalTime", "AverageTime"); if (GatherStatistics.timingMethod.Count == 0) { Console.WriteLine("no statistics loaded"); return(ret); } var data = GatherStatistics.DataGathered() .OrderByDescending(it => it.TotalDuration / it.NumberHits) .ToArray(); foreach (var item in data) { table.AddRow(item.m.className, $"{item.m.methodName}({item.m.line})", item.NumberHits, item.TotalDuration, (item.TotalDuration / item.NumberHits)); } table.Write(Format.Alternative); return(ret); }
public static void Clean() { var table = new ConsoleTable("Class", "Method(Line)", "NumberHit", "TotalTime", "AverageTime"); if (GatherStatistics.timingMethod.Count == 0) { Console.WriteLine("no statistics loaded"); return; } var data = GatherStatistics.DataGathered() .OrderByDescending(it => it.TotalDuration / it.NumberHits) .ToArray(); foreach (var item in data) { table.AddRow(item.m.className, $"{item.m.methodName}({item.m.line})", item.NumberHits, item.TotalDuration, (item.TotalDuration / item.NumberHits)); } var s = table.ToMarkDownString(); File.WriteAllText("statistics.txt", s); }