Skip to content

Commit

Permalink
Fixed up a few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eswann committed Aug 1, 2014
1 parent ef192fb commit 591eef8
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/Benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace Benchmark
{
class Program
{
private static decimal AutomapperTime;
private static decimal FprTime;

static void Main(string[] args)
{
try
Expand Down Expand Up @@ -77,6 +80,10 @@ private static void TestComplexTypes()

Test(customer, 100000);

Console.WriteLine();
Console.WriteLine("Automapper to Fpr ratio: " + (AutomapperTime/FprTime).ToString("###.00") + " X slower");
Console.WriteLine();

//Test(customer, 1000000);
}

Expand Down Expand Up @@ -146,14 +153,8 @@ private static void TestFprAdapter<TSrc, TDest>(TSrc item, int iterations)
where TSrc : class
where TDest : class, new()
{
Console.WriteLine("Fpr:\t\t\t" + Loop<TSrc>(item, get => TypeAdapter.Adapt<TSrc, TDest>(get), iterations));
}

private static void TestFmTypeAdapter<TSrc, TDest>(TSrc item, int iterations)
where TSrc : class
where TDest : class, new()
{
Console.WriteLine("FastMapper:\t\t" + Loop<TSrc>(item, get => Fm.TypeAdapter.Adapt<TSrc, TDest>(get), iterations));
FprTime = Loop<TSrc>(item, get => TypeAdapter.Adapt<TSrc, TDest>(get), iterations);
Console.WriteLine("Fpr:\t\t\t" + FprTime);
}


Expand All @@ -174,7 +175,8 @@ private static void TestAutoMapper<TSrc, TDest>(TSrc item, int iterations)
if(iterations > 500000)
Console.WriteLine("AutoMapper still working please wait...");

Console.WriteLine("AutoMapper:\t\t" + Loop(item, get => Mapper.Map<TSrc, TDest>(get), iterations));
AutomapperTime = Loop(item, get => Mapper.Map<TSrc, TDest>(get), iterations);
Console.WriteLine("AutoMapper:\t\t" + AutomapperTime);
}

private static long Loop<T>(T item, Action<T> action, int iterations = 1000000)
Expand Down

0 comments on commit 591eef8

Please sign in to comment.