Skip to content

Commit

Permalink
added statistics for test
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatandrei committed Aug 31, 2018
1 parent dc6ace7 commit 3291651
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
1 change: 1 addition & 0 deletions AOPRoslyn/TestAOP/TestAOP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
<PackageReference Include="PortableConsoleLibs" Version="1.0.0" />
<PackageReference Include="Shouldly" Version="3.0.0" />
</ItemGroup>

Expand Down
45 changes: 45 additions & 0 deletions AOPRoslyn/TestAOP/TestInitializeAll.cs
Original file line number Diff line number Diff line change
@@ -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);


}
}
}
3 changes: 0 additions & 3 deletions AOPRoslyn/processme.bat

This file was deleted.

0 comments on commit 3291651

Please sign in to comment.