Git Product home page Git Product logo

spring-comparing-template-engines's Introduction

#Comparing Template engines for Spring MVC

Build Status

This is a demo project to show the differences among several Java template engines in combination with Spring MVC. Template engines used in this project are:

Build and run

You need Java 7 and Maven 3 to build and run this project. Build the project with

mvn package

Run the project with

mvn tomcat7:run

See the demo URLs:

Benchmarking

In case you want to benchmark the different template engines I would recommend using Apache HTTP server benchmarking tool or Siege an HTTP/HTTPS stress tester.

$ ab -n 10000 -c 10 http://localhost:8080/jsp
$ ab -n 10000 -c 10 http://localhost:8080/velocity
$ ab -n 10000 -c 10 http://localhost:8080/freemarker
$ ab -n 10000 -c 10 http://localhost:8080/thymeleaf
$ ab -n 10000 -c 10 http://localhost:8080/mustache
$ ab -n 10000 -c 10 http://localhost:8080/jade

On my local machine with the following specs I did some benchmarks.

Mac OS X Version 10.8.5
2.53 GHz Intel Core 2 Duo
Java(TM) SE Runtime Environment (build 1.7.0_21-b12)
Tomcat 7.0.41 with 512M RAM

For creating my benchmarks I used ApacheBench, Version 2.3 <$Revision: 1430300 $> with the following settings:

ab -n 25000 -c 25 http://localhost:8080/jsp

With 25 concurrent requests and 25.000 requests in total this resulted in the following numbers:

Thymeleaf				21.8436 seconds
Jade4j					13.7044 seconds
Scalate - Scaml			12.1704 seconds
Mustache (JMustache)	8.8148 seconds
Freemarker				8.5574 seconds
Velocity				8.5052 seconds
JSP						8.8278 seconds
						

###How were the results measured?

Before the performance of each template engines was measured, there were at least 2 dry runs with the exact same settings, to make sure that initialization of the engines, warm up of the JVM and additional caches have taken place. There were at least 5 iterations of the same benchmark before calculating the average time it took.

###For Mac OSX users

Mac OS X has only 16K ports available that won't be released until socket TIME_WAIT is passed. The default timeout for TIME_WAIT is 15 seconds. Consider reducing in case of available port bottleneck.

You can check whether this is a problem with netstat:

# sysctl net.inet.tcp.msl
net.inet.tcp.msl: 15000

Now if you want to change this you can do so by doing:

# sudo sysctl -w net.inet.tcp.msl=1000
net.inet.tcp.msl: 15000 -> 1000

In case you see an improvement to the benchmark or know about ways to improve the results, please file an issue and send a pull request.

spring-comparing-template-engines's People

Contributors

greenlaw110 avatar jreijn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.