Performance improvement of freemarker-tags

For most applications the time spent in generating the outputs of their views is small and therefore any improvement in this aspect will be negligible.
For applications sensitive to that time, freemarker-tags has been redesigned, improving its performance. In version 0.7.0 of the plugin, the rendering speed of Grails Tag Libraries in a FTL template, is very close to that of a compiled GSP page:

A) quick_start application started using ‘grails prod run-war’ and tested using ‘ab-n 3000-c 30 url’

#request/second (mean)

freemarker-tags-0.6.1

list: 165.99 #/sec, 403.29 #/sec, 448.74 #/sec, 421.15 #/sec
create: 201.49 #/sec, 407.45 #/sec, 449.79 #/sec, 436.02 #/sec
show: 231.39 #/sec, 428.36 #/sec, 496.63 #/sec, 468.14 #/sec
edit: 186.29 #/sec, 348.25 #/sec, 388.07 #/sec, 372.15 #/sec

gsp

list: 248.94 #/sec, 714.39 #/sec, 777.56 #/sec, 688.66 #/sec
create: 251.24 #/sec, 712.82 #/sec, 891.65 #/sec, 813.68 #/sec
show: 250.04 #/sec, 742.08 #/sec, 990.49 #/sec, 918.49 #/sec
edit: 230.59 #/sec, 720.73 #/sec, 903.11 #/sec, 783.17 #/sec

freemarker-tags-0.7.0

list: 222.27 #/sec, 670.82 #/sec, 720.34 #/sec, 627.70 #/sec
create: 218.92 #/sec, 618.93 #/sec, 750.98 #/sec, 695.02 #/sec
show: 250.08 #/sec, 786.39 #/sec, 1040.83 #/sec, 878.74 #/sec
edit: 211.43 #/sec, 636.35 #/sec, 823.98 #/sec, 757.29 #/sec

In particular situations, the performance of a FTL template will be even better than a GSP page, thanks to FreeMarker itself:

B) dynamic_rendering application started using ‘grails run-app’ and tested using ‘ab-n 3000-c 30 url’


freemarker-tags-0.6.1

Template Creation: 9687ms, 8652ms, 8142ms, 8056ms, 8068ms
Rendering: 14188ms, 9820ms, 9184ms, 8944ms, 8913ms
Both: 17489ms, 17655ms, 17698ms, 17575ms, 17629ms

gsp

Template Creation: java.lang.OutOfMemoryError: PermGen space
Rendering: 12492ms, 8571ms, 7680ms, 7293ms, 7280ms
Both: ?

freemarker-tags-0.7.0

Template Creation: 9630ms, 8640ms, 8182ms, 8204ms, 8216ms
Rendering: 8740ms, 5861ms, 5156ms, 4933ms, 4941ms
Both: 13377ms, 13327ms, 13374ms, 13273ms, 13240ms

C) dynamic_rendering application started using ‘grails run-app’ and tested using ‘ab-n 3000-c 30 url’


freemarker-tags-0.6.1
Template Creation: 9924ms, 8725ms, 8027ms, 7969ms, 7950ms
Rendering: 13098ms, 8682ms, 8035ms, 7827ms, 7860ms
Both: 16271ms, 16271ms, 16194ms, 16178ms, 16176ms

gsp

Template Creation: java.lang.OutOfMemoryError: PermGen space
Rendering: 10687ms, 7084ms, 6311ms, 5941ms, 5867ms
Both: java.lang.OutOfMemoryError: PermGen space at gspTemplate415:63

freemarker-tags-0.7.0

Template Creation: 9941ms, 8556ms, 8028ms, 7868ms, 7864ms
Rendering: 8900ms, 5646ms, 4855ms, 4747ms, 4748ms
Both: 13014ms, 13034ms, 13001ms, 13018ms, 12953ms

The time of “dynamic rendering” is the same time that the developer perceives during the cycle change <-> refresh of the view. For a reference, open the URLs http://localhost:8080/dynamic_rendering/benchmark/freemarkerPage and http://localhost:8080/dynamic_rendering/benchmark/gspPage using different tabs of your browser, and for each, hit the “refresh” button a few times.

Project on GitHub.
Download the source code and complete results.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


6 + five =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>