From 3291651c0a638e9202a45e0132fa1d55d7b339a8 Mon Sep 17 00:00:00 2001 From: ignatandrei Date: Fri, 31 Aug 2018 09:04:54 +0300 Subject: [PATCH] added statistics for test --- AOPRoslyn/TestAOP/TestAOP.csproj | 1 + AOPRoslyn/TestAOP/TestInitializeAll.cs | 45 ++++++++++++++++++++++++++ AOPRoslyn/processme.bat | 3 -- 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 AOPRoslyn/TestAOP/TestInitializeAll.cs delete mode 100644 AOPRoslyn/processme.bat diff --git a/AOPRoslyn/TestAOP/TestAOP.csproj b/AOPRoslyn/TestAOP/TestAOP.csproj index 5b03e4f..9728912 100644 --- a/AOPRoslyn/TestAOP/TestAOP.csproj +++ b/AOPRoslyn/TestAOP/TestAOP.csproj @@ -27,6 +27,7 @@ + diff --git a/AOPRoslyn/TestAOP/TestInitializeAll.cs b/AOPRoslyn/TestAOP/TestInitializeAll.cs new file mode 100644 index 0000000..b5558ad --- /dev/null +++ b/AOPRoslyn/TestAOP/TestInitializeAll.cs @@ -0,0 +1,45 @@ +using AOPStatistics; +using ConsoleTables; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace TestAOP +{ + [TestClass] + public class TestInitializeAll + { + [AssemblyInitialize] + public static void Init(TestContext testContext) + { + Console.WriteLine("test initialize"); + Console.WriteLine("ither clean!"); + } + [AssemblyCleanup] + 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.ToStringAlternative(); + File.WriteAllText("statistics.txt", s); + + + } + } +} diff --git a/AOPRoslyn/processme.bat b/AOPRoslyn/processme.bat deleted file mode 100644 index c856311..0000000 --- a/AOPRoslyn/processme.bat +++ /dev/null @@ -1,3 +0,0 @@ -dotnet aop processme.txt -dotnet build -dotnet test TestAOP\TestAOP.csproj \ No newline at end of file