Skip to content

Instantly share code, notes, and snippets.

@fordguo
Created May 28, 2012 15:37
Show Gist options
  • Save fordguo/2819770 to your computer and use it in GitHub Desktop.
Save fordguo/2819770 to your computer and use it in GitHub Desktop.
gsp template render
def out = new org.codehaus.groovy.grails.web.pages.FastStringWriter()
def test1Instance = new Test1(prop2: "This is gsp test")
long startTime = System.currentTimeMillis()
def t=groovyPagesTemplateEngine.createTemplate(gspTemplateCode, 'gspTemplate')
for (int i = 0; i < TIMES; i++) {
t.make([test1Instance: test1Instance]).writeTo(out)
out.flush()
println "Executing... $i"
}
response.setContentType("text/json;charset=UTF-8")
long timeTaken = System.currentTimeMillis() - startTime
render '{"message":"' + TIMES + ' times completed in ' + timeTaken + 'ms."}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment