Thymeleaf template performance test

Source: Internet
Author: User

1 beetl

2 freemarker

3 thymeleaf

You can view the introduction of these three templates on oschina. I am familiar with the first two templates and have a new understanding of thymeleaf. I like thymeleaf very much, the static or dynamic opening of the template page can be displayed normally, facilitating front-end testing and backend separate development. The following is a test of the performance of the three.

Through @ idle. Big Fu, find the test tool Teb, http://git.oschina.net/kiang/teb @ Kiang

__________________________________________________________________________________________________________________________

We found that the beetl and freemarker test code has been implemented, so we added thymeleaf. Here I am using thymeleaf for the first time, so it is unclear whether thymeleaf configuration has an impact on its performance, the following code is used:

package kiang.tei;import kiang.teb.TebEngine;import kiang.teb.TebModel;import org.thymeleaf.TemplateEngine;import org.thymeleaf.context.Context;import org.thymeleaf.templateresolver.FileTemplateResolver;import java.io.OutputStream;import java.io.OutputStreamWriter;import java.io.Writer;import java.util.HashMap;import java.util.Map;import java.util.Properties;/** * @author eyeLee([email protected]) *         Time 2014/11/1. */public class Thymeleaf implements TebEngine {    private TemplateEngine engine;    @Override    public TebEngine init(Properties properties) throws Exception {        FileTemplateResolver templateResolver =  new FileTemplateResolver();        templateResolver.setPrefix("./src/kiang/tpl/");        templateResolver.setSuffix(".tpl");        templateResolver.setCharacterEncoding("UTF-8");        templateResolver.setTemplateMode("XHTML");        engine = new TemplateEngine();        engine.setTemplateResolver(templateResolver);        engine.initialize();        return this;    }    @Override    public void test(Map arguments, Writer writer) throws Exception {        Context ctx = new Context();        ctx.setVariables(arguments);        engine.process("thymeleaf",  ctx, writer);    }    @Override    public void test(Map arguments, OutputStream output) throws Exception {    }    @Override    public void shut() throws Exception {    }    @Override    public boolean isBinarySupport() {        return false;    }    public static void main(String args[]) throws Exception {        String source="UTF-8", target = "UTF-8";        Writer writer = new OutputStreamWriter(System.out, target);        Map data = new HashMap();        data.put("target", target);        data.put("models", TebModel.dummyModels(20));        Properties properties = new Properties();        properties.setProperty("source", source);        properties.setProperty("target", target);        properties.setProperty("binary", String.valueOf(true));        TebEngine engine = new Thymeleaf().init(properties);        engine.test(data, writer);        writer.flush();        engine.shut();    }}

Page code:

<HTML>  

Add the thymeleaf entry to the Teb configuration file:

#Thymeleafthy.name=Thymeleaf 2.1.3thy.site=http://thymeleaf.comthy.test=kiang.tei.Thymeleaf

Full Code address: http://git.oschina.net/yinjun622/teb

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Test results:

TPS: The engine throughput. The number of engine rendering times per unit of time. Unit: Times/second time: the execution time of all engine rendering. Unit: millisecond onceio: the number of I/O times of a single engine rendering, unit: The number of I/O operations rendered by the engine. Unit: onceout: the number of output bytes (characters) for a single rendering by the engine. Unit: Byte/character massout: the number of output bytes (characters) rendered by the engine. Unit: Byte/character permmem: memory consumption. The memory is out of the new generation of memory (the new generation of memory will be quickly recycled). Unit: byte

The test results show that thymeleaf and beetl are not in the same order of magnitude, and there is a huge gap in concurrency and rendering time.

Thymeleaf template performance test

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.