Do mappers cause slow down during runtime?

Saiteja Pamulapati :

In my spring-boot application, I have 3 layers: application (where rest controllers and DTO objects are placed), core (where main business logic is carried) and database (repositories and entities). I am using mappers between these layers to convert entity models that I retrieved from the repository to domain objects, which is used in the core layer, and to convert domain objects to DTOs to sent back to the user (if needed).

My question is, how much these mappers affect the run-time of application. Are they increase response time noticeably?

In my case, I am using orika mapper.

Saiteja Pamulapati :

I have found a nice explanation in Baeldung, which compares various mapping frameworks for java. Depending on the framework, the time spend on mapping might is different and MapStruct shows the best performance while Dozer mapper has the lowest results.

Here is the real-life model testing of 5 frameworks to measure the average running time per operation:

enter image description here

Orika mapper (0.01 ms per operation) is not noticeable by the end-user in case the number of operations is not extremely high.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=12556&siteId=1