I have migrated my code to generate a file using Xpand template to Freemarker template for performance improvements. But i still see some performance problems with freemarker. Below two methods are taking 40 sec together, see snapshot. Is there a way to improve the performance?
Thanks in advance.
Seems like template parsing dominates in your workload. While FreeMarker parsing is not particularly slow (for a relatively complex language parser), FreeMarker was designed with the assumption that you parse a template only once (which yields a Template
object, that contains the template in an already parsed form), and then run ("process") it for many times. That is, that you will re-use the same Template
object for several Template.process
calls (that's what generates the actual output), each time with a potentially different data-model. Normally, if you get templates from Configuration
(which should be a singleton, as opposed to being re-created again and again), those Template
objects are cached. If you are creating Template
-s with the Template
constructor, then those are of course not cached, and re-using them is up to you.
I used latest version of free-marker jar, the performance is 80% better than before.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.