Skip to content

Latest commit

 

History

History
192 lines (131 loc) · 8.48 KB

README.md

File metadata and controls

192 lines (131 loc) · 8.48 KB

← .NET Matrix · Open the interactive matrix →

Object Mapping

Mapperly leads the current rating · 4 libraries · 10 scenarios

Rating

In every scenario the fastest library scores 100 points and the one allocating least scores 100 more; four times slower is half the points, and an unsupported scenario is worth nothing. Time and memory reach 1000 each here, so the maximum is 2000. See workflows/rating.md.

Object Mapping rating

# Library Scenarios Time Memory Points Group wins
1 Mapperly 10/10 1000 1000 2000 gold in Advanced, gold in Basic, gold in Prepare
2 Mapster 10/10 576 792 1367 silver in Advanced, silver in Basic, bronze in Prepare
3 AutoMapper 10/10 464 802 1265 silver in Prepare, bronze in Advanced, bronze in Basic
How the points were earned — every scenario, with the measurements behind it

Each row is one scenario. Best is the lowest result among the rated libraries that completed it, and the points follow from the two figures beside them: 100 × √((best + step) / (result + step)), with a step of 1 ns for time and 24 B for memory. A dash means the library did not complete the scenario, and it scores nothing for it. Add the two Points columns over every scenario and you get the rating above. The same breakdown appears as a hint on any points value in the application.

1. Mapperly — 2000 of 2000

Scenario Time Best Points Memory Best Points
Simple Object 9.09 ns 9.09 ns 100 56 B 56 B 100
Nested Object 42.11 ns 42.11 ns 100 248 B 248 B 100
Collection 859.89 ns 859.89 ns 100 6.27 KB 6.27 KB 100
Flattening 10.48 ns 10.48 ns 100 56 B 56 B 100
Map To Existing 3.65 ns 3.65 ns 100 0 B 0 B 100
Null Handling 8.11 ns 8.11 ns 100 40 B 40 B 100
Custom Conversion 59.23 ns 59.23 ns 100 88 B 88 B 100
Polymorphic Mapping 29.11 ns 29.11 ns 100 144 B 144 B 100
Prepare Configuration 0 ns 0 ns 100 0 B 0 B 100
Prepare And Simple Map 9 ns 9 ns 100 56 B 56 B 100

2. Mapster — 1367 of 2000

Scenario Time Best Points Memory Best Points
Simple Object 19.54 ns 9.09 ns 70.1 56 B 56 B 100
Nested Object 60.53 ns 42.11 ns 83.7 248 B 248 B 100
Collection 1.02 μs 859.89 ns 91.9 6.27 KB 6.27 KB 100
Flattening 19.25 ns 10.48 ns 75.3 56 B 56 B 100
Map To Existing 10.95 ns 3.65 ns 62.4 0 B 0 B 100
Null Handling 27.18 ns 8.11 ns 56.9 40 B 40 B 100
Custom Conversion 87.36 ns 59.23 ns 82.6 112 B 88 B 90.7
Polymorphic Mapping 106.33 ns 29.11 ns 53 144 B 144 B 100
Prepare Configuration 20.89 ms 0 ns 0.022 2.43 MB 0 B 0.307
Prepare And Simple Map 21.43 ms 9 ns 0.068 2.56 MB 56 B 0.545

3. AutoMapper — 1265 of 2000

Scenario Time Best Points Memory Best Points
Simple Object 43.54 ns 9.09 ns 47.6 56 B 56 B 100
Nested Object 86.24 ns 42.11 ns 70.3 248 B 248 B 100
Collection 900.1 ns 859.89 ns 97.7 6.27 KB 6.27 KB 100
Flattening 44.7 ns 10.48 ns 50.1 56 B 56 B 100
Map To Existing 38.94 ns 3.65 ns 34.1 0 B 0 B 100
Null Handling 43.89 ns 8.11 ns 45.1 40 B 40 B 100
Custom Conversion 94.19 ns 59.23 ns 79.5 88 B 88 B 100
Polymorphic Mapping 197.52 ns 29.11 ns 38.9 144 B 144 B 100
Prepare Configuration 11.91 ms 0 ns 0.029 624.08 KB 0 B 0.613
Prepare And Simple Map 12.71 ms 9 ns 0.089 657.28 KB 56 B 1.09

Benchmark overview

Basic

Object Mapping Basic benchmark overview

More overview charts (2)

Advanced

Object Mapping Advanced benchmark overview

Prepare

Object Mapping Prepare benchmark overview

Compared libraries (4)

AutoMapper logo AutoMapper 16.2.0
A convention-based object-object mapper with runtime configuration and compiled mapping plans.
Compare →
Hand-coded logo Hand-coded
Direct object mapping written in C# without a mapping library.
Compare →
Mapperly logo Mapperly 4.3.1
A source generator that creates readable object mapping code at compile time.
Compare →
Mapster logo Mapster 10.0.14
An object mapper with runtime configuration, expression compilation, and projection support.
Compare →

Benchmark scenarios (10)

01 · Simple Object

Maps one object with scalar values to a newly allocated destination object.

Object Mapping Simple Object benchmark

02 · Nested Object

Maps an order with nested customer and address objects to a new destination graph.

Object Mapping Nested Object benchmark

03 · Collection

Maps an array of 100 objects while preserving count, order and member values.

Object Mapping Collection benchmark

04 · Flattening

Maps nested customer values into a flat order summary through member-path configuration.

Object Mapping Flattening benchmark

05 · Map To Existing

Overwrites a supplied destination object and returns that same instance.

Object Mapping Map To Existing benchmark

06 · Null Handling

Preserves null text, nested object and collection members in the destination.

Object Mapping Null Handling benchmark

07 · Custom Conversion

Maps string values through registered code and invariant decimal conversions.

Object Mapping Custom Conversion benchmark

08 · Polymorphic Mapping

Maps a base array containing cats and dogs to matching destination runtime types.

Object Mapping Polymorphic Mapping benchmark

09 · Prepare Configuration

Creates the complete mapper configuration and eagerly prepares its runtime mapping plans.

Object Mapping Prepare Configuration benchmark

10 · Prepare And Simple Map

Creates the complete mapper configuration and maps one simple object.

Object Mapping Prepare And Simple Map benchmark