Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AnnotationRandomizerRegistry should cache and reuse randomizers to improve performance #365

Closed
joinghel opened this issue Jul 5, 2019 · 1 comment
Milestone

Comments

@joinghel
Copy link

joinghel commented Jul 5, 2019

The current implementation of AnnotationRandomizerRegistry creates a new randomizer for each random object, which is not ideal for perfomance.

Randomizer randomizer = (Randomizer) field.getAnnotation(Randomizer.class);
Class<?> type = randomizer.value();
RandomizerArgument[] arguments = randomizer.args();
return ReflectionUtils.newInstance(type, arguments);

@benas would it be a good solution to add a Map<Field, Randomizer<?>> similar to the one in CustomRandomizerRegistry and populate the map for every new encountered field? I'd like to try my luck with a PR :)

fmbenhassine pushed a commit that referenced this issue Oct 25, 2019
@fmbenhassine fmbenhassine added this to the 4.1.0 milestone Oct 25, 2019
@fmbenhassine
Copy link
Member

This is awesome! Thank you for reporting the case and for the PR 👍 Closing this after merging #366 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants