3

Currently, modelMapper.map to convert from DTO to entity and the other way around takes approximately 3 s.

Is that normal? Currently, this entity has 12 variables that are using ManyToOne relation.

Previously, it takes 5 s for a single map.

But after I use modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); now only takes 3 s.

Rilos
  • 31
  • 2

1 Answers1

1

Constructing new ModelMapper instance is generally CPU intensive depending on the complexity of your bindings. You should avoid building new ModelMapper instances for every use and focus on reusing/sharing built instances. If you have different mapping requirements, stash the different shapes in a lookup and compute them lazily when absent.

Ashwin Prabhu
  • 9,285
  • 5
  • 49
  • 82