diff --git a/src/Benchmark/Benchmark.csproj b/src/Benchmark/Benchmark.csproj index ba4b6b9f..b6872ab8 100644 --- a/src/Benchmark/Benchmark.csproj +++ b/src/Benchmark/Benchmark.csproj @@ -19,11 +19,10 @@ - + - - + diff --git a/src/Benchmark/Benchmarks/TestAll.cs b/src/Benchmark/Benchmarks/TestAll.cs index 40388f24..17581ddf 100644 --- a/src/Benchmark/Benchmarks/TestAll.cs +++ b/src/Benchmark/Benchmarks/TestAll.cs @@ -11,47 +11,47 @@ public class TestAll [Params(100_000)]//, 1_000_000)] public int Iterations { get; set; } - [Benchmark(Description = "Mapster 7.2.0")] + [Benchmark(Description = $"Mapster {TestAdaptHelper.MapsterVersion}")] public void MapsterTest() { TestAdaptHelper.TestMapsterAdapter(_fooInstance, Iterations); TestAdaptHelper.TestMapsterAdapter(_customerInstance, Iterations); } - [Benchmark(Description = "Mapster 7.2.0 (Roslyn)")] + [Benchmark(Description = $"Mapster {TestAdaptHelper.MapsterVersion} (Roslyn)")] public void RoslynTest() { TestAdaptHelper.TestMapsterAdapter(_fooInstance, Iterations); TestAdaptHelper.TestMapsterAdapter(_customerInstance, Iterations); } - [Benchmark(Description = "Mapster 7.2.0 (FEC)")] + [Benchmark(Description = $"Mapster {TestAdaptHelper.MapsterVersion} (FEC)")] public void FecTest() { TestAdaptHelper.TestMapsterAdapter(_fooInstance, Iterations); TestAdaptHelper.TestMapsterAdapter(_customerInstance, Iterations); } - [Benchmark(Description = "Mapster 7.2.0 (Codegen)")] + [Benchmark(Description = $"Mapster {TestAdaptHelper.MapsterVersion} (Codegen)")] public void CodegenTest() { TestAdaptHelper.TestCodeGen(_fooInstance, Iterations); TestAdaptHelper.TestCodeGen(_customerInstance, Iterations); } - [Benchmark(Description = "ExpressMapper 1.9.1")] + [Benchmark(Description = $"ExpressMapper {TestAdaptHelper.ExpressionMapperVersion}")] public void ExpressMapperTest() { TestAdaptHelper.TestExpressMapper(_fooInstance, Iterations); TestAdaptHelper.TestExpressMapper(_customerInstance, Iterations); } - [Benchmark(Description = "AutoMapper 10.1.1")] - public void AutoMapperTest() - { - TestAdaptHelper.TestAutoMapper(_fooInstance, Iterations); - TestAdaptHelper.TestAutoMapper(_customerInstance, Iterations); - } + //[Benchmark(Description = $"AutoMapper {TestAdaptHelper.AutoMapperVersion}")] + //public void AutoMapperTest() + //{ + // TestAdaptHelper.TestAutoMapper(_fooInstance, Iterations); + // TestAdaptHelper.TestAutoMapper(_customerInstance, Iterations); + //} [GlobalSetup(Target = nameof(MapsterTest))] public void SetupMapster() @@ -98,14 +98,14 @@ public void SetupExpressMapper() TestAdaptHelper.ConfigureExpressMapper(_customerInstance); } - [GlobalSetup(Target = nameof(AutoMapperTest))] - public void SetupAutoMapper() - { - _fooInstance = TestAdaptHelper.SetupFooInstance(); - _customerInstance = TestAdaptHelper.SetupCustomerInstance(); - TestAdaptHelper.ConfigureAutoMapper(_fooInstance); - TestAdaptHelper.ConfigureAutoMapper(_customerInstance); - } + //[GlobalSetup(Target = nameof(AutoMapperTest))] + //public void SetupAutoMapper() + //{ + // _fooInstance = TestAdaptHelper.SetupFooInstance(); + // _customerInstance = TestAdaptHelper.SetupCustomerInstance(); + // TestAdaptHelper.ConfigureAutoMapper(_fooInstance); + // TestAdaptHelper.ConfigureAutoMapper(_customerInstance); + //} } } \ No newline at end of file diff --git a/src/Benchmark/Benchmarks/TestComplexTypes.cs b/src/Benchmark/Benchmarks/TestComplexTypes.cs index 971f2e73..a61ca9d3 100644 --- a/src/Benchmark/Benchmarks/TestComplexTypes.cs +++ b/src/Benchmark/Benchmarks/TestComplexTypes.cs @@ -16,13 +16,13 @@ public void MapsterTest() TestAdaptHelper.TestMapsterAdapter(_customerInstance, Iterations); } - [Benchmark(Description = "Mapster 6.0.0 (Roslyn)")] + [Benchmark(Description = $"Mapster {TestAdaptHelper.MapsterVersion} (Roslyn)")] public void RoslynTest() { TestAdaptHelper.TestMapsterAdapter(_customerInstance, Iterations); } - [Benchmark(Description = "Mapster 6.0.0 (FEC)")] + [Benchmark(Description = $"Mapster {TestAdaptHelper.MapsterVersion} (FEC)")] public void FecTest() { TestAdaptHelper.TestMapsterAdapter(_customerInstance, Iterations); @@ -40,11 +40,11 @@ public void ExpressMapperTest() TestAdaptHelper.TestExpressMapper(_customerInstance, Iterations); } - [Benchmark] - public void AutoMapperTest() - { - TestAdaptHelper.TestAutoMapper(_customerInstance, Iterations); - } + //[Benchmark] + //public void AutoMapperTest() + //{ + // TestAdaptHelper.TestAutoMapper(_customerInstance, Iterations); + //} [GlobalSetup(Target = nameof(MapsterTest))] public void SetupMapster() @@ -81,11 +81,11 @@ public void SetupExpressMapper() TestAdaptHelper.ConfigureExpressMapper(_customerInstance); } - [GlobalSetup(Target = nameof(AutoMapperTest))] - public void SetupAutoMapper() - { - _customerInstance = TestAdaptHelper.SetupCustomerInstance(); - TestAdaptHelper.ConfigureAutoMapper(_customerInstance); - } + //[GlobalSetup(Target = nameof(AutoMapperTest))] + //public void SetupAutoMapper() + //{ + // _customerInstance = TestAdaptHelper.SetupCustomerInstance(); + // TestAdaptHelper.ConfigureAutoMapper(_customerInstance); + //} } } \ No newline at end of file diff --git a/src/Benchmark/Benchmarks/TestSimpleTypes.cs b/src/Benchmark/Benchmarks/TestSimpleTypes.cs index 7c832a56..81f507e5 100644 --- a/src/Benchmark/Benchmarks/TestSimpleTypes.cs +++ b/src/Benchmark/Benchmarks/TestSimpleTypes.cs @@ -16,13 +16,13 @@ public void MapsterTest() TestAdaptHelper.TestMapsterAdapter(_fooInstance, Iterations); } - [Benchmark(Description = "Mapster 6.0.0 (Roslyn)")] + [Benchmark(Description = $"Mapster {TestAdaptHelper.MapsterVersion} (Roslyn)")] public void RoslynTest() { TestAdaptHelper.TestMapsterAdapter(_fooInstance, Iterations); } - [Benchmark(Description = "Mapster 6.0.0 (FEC)")] + [Benchmark(Description = $"Mapster {TestAdaptHelper.MapsterVersion} (FEC)")] public void FecTest() { TestAdaptHelper.TestMapsterAdapter(_fooInstance, Iterations); @@ -40,11 +40,11 @@ public void ExpressMapperTest() TestAdaptHelper.TestExpressMapper(_fooInstance, Iterations); } - [Benchmark] - public void AutoMapperTest() - { - TestAdaptHelper.TestAutoMapper(_fooInstance, Iterations); - } + //[Benchmark] + //public void AutoMapperTest() + //{ + // TestAdaptHelper.TestAutoMapper(_fooInstance, Iterations); + //} [GlobalSetup(Target = nameof(MapsterTest))] @@ -82,11 +82,11 @@ public void SetupExpressMapper() TestAdaptHelper.ConfigureExpressMapper(_fooInstance); } - [GlobalSetup(Target = nameof(AutoMapperTest))] - public void SetupAutoMapper() - { - _fooInstance = TestAdaptHelper.SetupFooInstance(); - TestAdaptHelper.ConfigureAutoMapper(_fooInstance); - } + //[GlobalSetup(Target = nameof(AutoMapperTest))] + //public void SetupAutoMapper() + //{ + // _fooInstance = TestAdaptHelper.SetupFooInstance(); + // TestAdaptHelper.ConfigureAutoMapper(_fooInstance); + //} } } \ No newline at end of file diff --git a/src/Benchmark/TestAdaptHelper.cs b/src/Benchmark/TestAdaptHelper.cs index 3d7db0eb..cf8918e2 100644 --- a/src/Benchmark/TestAdaptHelper.cs +++ b/src/Benchmark/TestAdaptHelper.cs @@ -1,22 +1,26 @@ -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using AutoMapper; -using Benchmark.Classes; +using Benchmark.Classes; using FastExpressionCompiler; using Mapster; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; namespace Benchmark { public static class TestAdaptHelper { - private static readonly IMapper _mapper = new Mapper(new MapperConfiguration(cfg => - { - cfg.CreateMap(); - cfg.CreateMap(); - cfg.CreateMap(); - cfg.CreateMap(); - })); + //private static readonly IMapper _mapper = new Mapper(new MapperConfiguration(cfg => + //{ + // cfg.CreateMap(); + // cfg.CreateMap(); + // cfg.CreateMap(); + // cfg.CreateMap(); + //})); + + public const string MapsterVersion = "10.0.0"; + public const string AutoMapperVersion = "13.0.0"; + public const string ExpressionTranslatorVersion = "2.5.0"; + public const string ExpressionMapperVersion = "1.9.1"; public static Customer SetupCustomerInstance() { @@ -90,10 +94,10 @@ public static void ConfigureExpressMapper(Foo fooInstance) { //ExpressMapper.Mapper.Map(fooInstance); //exercise } - public static void ConfigureAutoMapper(Foo fooInstance) - { - _mapper.Map(fooInstance); //exercise - } + //public static void ConfigureAutoMapper(Foo fooInstance) + //{ + // _mapper.Map(fooInstance); //exercise + //} public static void ConfigureMapster(Customer customerInstance, MapsterCompilerType type) { @@ -105,10 +109,10 @@ public static void ConfigureExpressMapper(Customer customerInstance) { //ExpressMapper.Mapper.Map(customerInstance); //exercise } - public static void ConfigureAutoMapper(Customer customerInstance) - { - _mapper.Map(customerInstance); //exercise - } + //public static void ConfigureAutoMapper(Customer customerInstance) + //{ + // _mapper.Map(customerInstance); //exercise + //} public static void TestMapsterAdapter(TSrc item, int iterations) where TSrc : class @@ -124,12 +128,12 @@ public static void TestExpressMapper(TSrc item, int iterations) //Loop(item, get => ExpressMapper.Mapper.Map(get), iterations); } - public static void TestAutoMapper(TSrc item, int iterations) - where TSrc : class - where TDest : class, new() - { - Loop(item, get => _mapper.Map(get), iterations); - } + //public static void TestAutoMapper(TSrc item, int iterations) + // where TSrc : class + // where TDest : class, new() + //{ + // Loop(item, get => _mapper.Map(get), iterations); + //} public static void TestCodeGen(Foo item, int iterations) {