Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
chaowlert committed Mar 1, 2020
2 parents 768aba8 + a514460 commit adf6c17
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 22 deletions.
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ using (MyDbContext context = new MyDbContext())
}
```

### What's new in Mapster 4.0
- Two ways mapping
- Unflattening
- Map & ignore by property path
- MaxDepth
- Map to constructor
### What's new in Mapster 5.0
- [Generate dynamic proxy for interface](https://github.com/MapsterMapper/Mapster/blob/master/src/Mapster.Tests/WhenMappingToInterface.cs)
- [UseDestinationValue](https://github.com/MapsterMapper/Mapster/wiki/Mapping-readonly-prop)
- [Null propagating for property path](https://github.com/MapsterMapper/Mapster/wiki/Custom-mapping#null-propagation)
- [Support multiple sources](https://github.com/MapsterMapper/Mapster/wiki/Custom-mapping#multiple-sources)
- New plugins
- [Async support](https://github.com/MapsterMapper/Mapster/wiki/Async)
- [Inject service to mapping](https://github.com/MapsterMapper/Mapster/wiki/Dependency-Injection)
- [EF Core support](https://github.com/MapsterMapper/Mapster/wiki/EF-6-&-EF-Core)

### Why Mapster?
#### Performance & Memory efficient
Expand All @@ -60,20 +63,21 @@ And you could gain to 12x faster with

| Method | Mean | StdDev | Error | Gen 0 | Gen 1 | Gen 2 | Allocated |
|-------------------------- |---------------:|-------------:|-------------:|------------:|------:|------:|-----------:|
| 'Mapster 4.1.1' | 115.31 ms | 0.849 ms | 1.426 ms | 31000.0000 | - | - | 124.36 MB |
| 'Mapster 4.1.1 (Roslyn)' | 53.55 ms | 0.342 ms | 0.654 ms | 31100.0000 | - | - | 124.36 MB |
| 'Mapster 4.1.1 (FEC)' | 54.70 ms | 1.023 ms | 1.546 ms | 29600.0000 | - | - | 118.26 MB |
| 'Mapster 4.1.1 (Codegen)' | 48.22 ms | 0.868 ms | 1.312 ms | 31090.9091 | - | - | 124.36 MB |
| 'ExpressMapper 1.9.1' | 260.04 ms | 6.340 ms | 9.585 ms | 59000.0000 | - | - | 236.51 MB |
| 'AutoMapper 9.0.0' | 601.23 ms | 3.869 ms | 6.501 ms | 87000.0000 | - | - | 350.95 MB |
| 'Mapster 5.0.0' | 141.84 ms | 0.931 ms | 1.408 ms | 31250.0000 | - | - | 125.12 MB |
| 'Mapster 5.0.0 (Roslyn)' | 60.48 ms | 1.186 ms | 1.993 ms | 31222.2222 | - | - | 125.12 MB |
| 'Mapster 5.0.0 (FEC)' | 58.17 ms | 0.231 ms | 0.442 ms | 29714.2857 | - | - | 119.02 MB |
| 'Mapster 5.0.0 (Codegen)' | 51.56 ms | 0.312 ms | 0.524 ms | 31200.0000 | - | - | 125.12 MB |
| 'ExpressMapper 1.9.1' | 299.05 ms | 2.081 ms | 3.146 ms | 60000.0000 | - | - | 241.85 MB |
| 'AutoMapper 9.0.0' | 708.06 ms | 3.398 ms | 5.137 ms | 91000.0000 | - | - | 364.69 MB |



#### Step into debugging

[Step-into debugging](https://github.com/MapsterMapper/Mapster/wiki/Debugging) lets you debug your mapping and inspect values as same as its your code.
![image](https://cloud.githubusercontent.com/assets/5763993/26521773/180427b6-431b-11e7-9188-10c01fa5ba5c.png)

#### Code Generation NEW!!
#### Code Generation
[Mapster CodeGen](https://github.com/MapsterMapper/Mapster/wiki/CodeGen) lets you do mapping with
- Validate mapping at compile time
- Getting raw performance
Expand All @@ -85,3 +89,11 @@ https://github.com/MapsterMapper/Mapster/releases

### Usages
https://github.com/MapsterMapper/Mapster/wiki

### Acknowledgements

[JetBrains](https://www.jetbrains.com/?from=Mapster) kindly provides Mapster with a free open-source licence for their Resharper and Rider.
- **Resharper** makes Visual Studio a much better IDE
- **Rider** is fast & powerful cross platform .NET IDE

![image](https://upload.wikimedia.org/wikipedia/commons/thumb/1/1a/JetBrains_Logo_2016.svg/121px-JetBrains_Logo_2016.svg.png)
10 changes: 5 additions & 5 deletions src/Benchmark/Benchmarks/TestAll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ public class TestAll
private Foo fooInstance;
private Customer customerInstance;

[Params(1000, 10_000, 100_000)]//, 1_000_000)]
[Params(100_000)]//, 1_000_000)]
public int Iterations { get; set; }

[Benchmark(Description = "Mapster 4.1.1")]
[Benchmark(Description = "Mapster 5.0.0")]
public void MapsterTest()
{
TestAdaptHelper.TestMapsterAdapter<Foo, Foo>(fooInstance, Iterations);
TestAdaptHelper.TestMapsterAdapter<Customer, CustomerDTO>(customerInstance, Iterations);
}

[Benchmark(Description = "Mapster 4.1.1 (Roslyn)")]
[Benchmark(Description = "Mapster 5.0.0 (Roslyn)")]
public void RoslynTest()
{
TestAdaptHelper.TestMapsterAdapter<Foo, Foo>(fooInstance, Iterations);
TestAdaptHelper.TestMapsterAdapter<Customer, CustomerDTO>(customerInstance, Iterations);
}

[Benchmark(Description = "Mapster 4.1.1 (FEC)")]
[Benchmark(Description = "Mapster 5.0.0 (FEC)")]
public void FecTest()
{
TestAdaptHelper.TestMapsterAdapter<Foo, Foo>(fooInstance, Iterations);
TestAdaptHelper.TestMapsterAdapter<Customer, CustomerDTO>(customerInstance, Iterations);
}

[Benchmark(Description = "Mapster 4.1.1 (Codegen)")]
[Benchmark(Description = "Mapster 5.0.0 (Codegen)")]
public void CodegenTest()
{
TestAdaptHelper.TestCodeGen(fooInstance, Iterations);
Expand Down
4 changes: 2 additions & 2 deletions src/Benchmark/Benchmarks/TestComplexTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public void MapsterTest()
TestAdaptHelper.TestMapsterAdapter<Customer, CustomerDTO>(customerInstance, Iterations);
}

[Benchmark(Description = "Mapster 4.1.1 (Roslyn)")]
[Benchmark(Description = "Mapster 5.0.0 (Roslyn)")]
public void RoslynTest()
{
TestAdaptHelper.TestMapsterAdapter<Customer, CustomerDTO>(customerInstance, Iterations);
}

[Benchmark(Description = "Mapster 4.1.1 (FEC)")]
[Benchmark(Description = "Mapster 5.0.0 (FEC)")]
public void FecTest()
{
TestAdaptHelper.TestMapsterAdapter<Customer, CustomerDTO>(customerInstance, Iterations);
Expand Down
4 changes: 2 additions & 2 deletions src/Benchmark/Benchmarks/TestSimpleTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public void MapsterTest()
TestAdaptHelper.TestMapsterAdapter<Foo, Foo>(fooInstance, Iterations);
}

[Benchmark(Description = "Mapster 4.1.1 (Roslyn)")]
[Benchmark(Description = "Mapster 5.0.0 (Roslyn)")]
public void RoslynTest()
{
TestAdaptHelper.TestMapsterAdapter<Foo, Foo>(fooInstance, Iterations);
}

[Benchmark(Description = "Mapster 4.1.1 (FEC)")]
[Benchmark(Description = "Mapster 5.0.0 (FEC)")]
public void FecTest()
{
TestAdaptHelper.TestMapsterAdapter<Foo, Foo>(fooInstance, Iterations);
Expand Down

0 comments on commit adf6c17

Please sign in to comment.