[JAVA] Performance issues with AbstractJavaCodegen.toModelName()
Description
We are using swagger-codegen to generate Java code based on some OpenAPI specification. We noticed that the generation was taking a considerable amount of time so we decided to profile the generation. What we saw is that most of the time was spent inside AbstractJavaCodegen.toModelName(String name). After further investigation, we noticed that this method was being called 3390629 times and 3389750 of the times was for duplicated names. This means that only 879 times this method was being called with a unique name argument.
Just as a POC, we introduced a cache into this method and we got execution times up to 3x faster.
Here you can see a call stacktrace:
Let us know if there is more information we can provide.
Swagger-codegen version
4.0.0-beta3
Swagger declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
I haven't found any
Suggest a fix/enhancement
We were wondering if the introduction of a cache may be something you may want to consider. But we are not sure about the implications of such a cache.
We realize the swagger-codegen version is old. We will try to update to a newer version and check again.