Question: i've got a webscript in alfresco which is written in javascript. In this webscript i have a lot of recursion (foreach loops) to do to generate the values that are used by a freemarker template to build a JSON. The problem is that javascript is very slow (3700 milliseconds). I could achieve the same results by iterating in freemarker, but i don't know if it's worth the hassle writing complex loop in freemarker because i don't know if it's faster and i don't know how to benchmark it. 

Anyone knows if freemarker is faster than javascript or does anyone knows how to benchmark freemarker?

Answer: 
Some days ago somebody mentioned on the freemarker-devel mailing list that he benchmarked FreeMarker vs. GSP (Groovy Server Pages?). Maybe you can reuse some of his benchmarking stuff. There are some links in his [mailing list posting](http://thread.gmane.org/gmane.comp.web.freemarker.devel/7814).
If you want to compare for with forEach, some benchmarks are shown [here](http://www.symphonious.net/2010/10/09/javascript-performance-for-vs-foreach/) . 

You might want to set your own benchmark in [jsperf](http://jsperf.com/)