Twinify 1.0.2: A Look at the Latest Performance Improvements
Over the past few weeks, the performance and memory efficiency of Twinify has been improved, twinify is an open-source object-to-object mapping library for .NET. The latest release, Twinify 1.0.2 , brings some encouraging improvements compared with the initial 1.0.0 release. I also wanted to keep the benchmarking honest, so the tests include AutoMapper 16.2.0 as a reference point. Twinify is…
Twinify 1.0.2 is a new version of the open-source .NET object-to-object mapping library, Twinify. The latest release introduces notable performance improvements over its predecessor, Twinify 1.0.0, and also compares favorably with the AutoMapper 16.2.0 library.
The benchmark tests were conducted on a Windows 11 machine with an Intel Core i7-1355U processor, using .NET 10 and BenchmarkDotNet 0.15.8 tools. Twinify maps a complex object graph, including nested objects, collections, and constructor mapping.
In the single user mapping scenario, Twinify 1.0.0 took 3.819 μs, while Twinify 1.0.2 completed the task in 4.087 μs. When mapping 1,000 users, Twinify 1.0.0 took 4,420.174 μs, and Twinify 1.0.2 performed the same task in 2,420.444 μs, which is approximately a 45% reduction in execution time. The same performance gap with AutoMapper has become smaller, with AutoMapper completing the same benchmark in 1,108.267 μs.
The memory allocation and garbage collection (GC) activity also improved significantly. For the 1,000-user benchmark, Twinify 1.0.0 allocated 3,320,120 B of memory, while Twinify 1.0.2 allocated 1,864,120 B, representing approximately a 44% reduction in memory allocation. The Gen0 collections dropped from 523.4375 to 296.8750, which is approximately a 43% reduction. Similarly, the Gen1 collections decreased from 242.1875 to 171.8750, showing a 29% reduction.
Although AutoMapper 16.2.0 remains ahead in terms of raw performance, the significant improvements in Twinify 1.0.2 demonstrate a substantial reduction in memory allocation and GC pressure. The next optimization targets for Twinify include reducing mapping execution overhead, allocations during nested and collection mapping, reflection or dynamic dispatch on the hot path, and temporary objects and collections.
The current results already show that Twinify can continue closing the performance gap while maintaining a simple and predictable API.
Twinify is available on NuGet, and its documentation provides examples covering profiles, nested mappings, collections, dependency injection, and other mapping scenarios.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.