jknack / handlebars.java

Logic-less and semantic Mustache templates with Java
http://jknack.github.io/handlebars.java
Other
1.47k stars 382 forks source link

Performance issue #681

Open max3163 opened 5 years ago

max3163 commented 5 years ago

I use Wiremock which use your library for templating. I am encountering a problem of performance when I active the reponse templating especially when the response content is important ( start at 250Ko ) By example, for a full text response of 500Kb to parse for handlebar, I got a response time of 21 second ! ( even with the text content 0 function ! )

l_3892 tmp

The visitBody seem to be the problem.

jknack commented 5 years ago

Hi, make sure you install one of the cache implementation: https://github.com/jknack/handlebars.java#the-cache-system

Also, if you attach an example will look later to see if we really can improve something.

Thanks

max3163 commented 5 years ago

As I said, I don't use directly handlebar, I use Wiremock which use HandleBars. I can send you example, but it's a Wiremock example. I have open an issue on the Wiremock side too, I will inform them about the cache and try to know if they implement it.

jknack commented 5 years ago

ok, yea no idea what was wiremock. My guess is that there is no cache so ANTLR parses 500kb on every single call.

max3163 commented 5 years ago

I'm ok for the cache which could improved performance on multiple call, but 14 second in visitBody to parse 500Kb of text without any {{ }} function to call, I find it really bad.

philippe-granet commented 5 years ago

A solution like this https://github.com/tomakehurst/wiremock/pull/1088 could help on larges files