spring template benchmark with script template and react server-side-rendering et all
getting started:
$ mvn spring-boot:run -Drun.profiles=<profile>
profiles:
- thymeleaf
- freemarker
- velocity
- jsp
- handlebars (with ScriptTemplateView with nashorn engine)
- ejs (with ScriptTemplateView using nashorn engine)
- [v8ejs] (with custom template view using [v8] only)
- ...
endpoints:
- http://localhost:8080/ server-side template, as usual
- http://localhost:8080/react/nashorn react rendering on server with nashorn
- http://localhost:8080/react/v8 react rendering on server with j2v8 (NOTE: ScriptTemplateView still uses nashorn)
- http://localhost:8080/react/v8ejs pure v8 template + react rendering with j2v8 (
v8ejs
profile only) - http://localhost:8080/react.html react rendering on browser
- ...
result on my laptop:
- MacBook Pro (Retina, 15-inch, Mid 2014)
- 2.5 GHz Intel Core i7, 16GB 1600 MHz DDR3, 500GB Apple SSD
/ | /react/nashorn | /react/v8 | /react/v8ejs | |
---|---|---|---|---|
ejs | 84.40 | 30.10 | 86.39 | - |
freemarker | 216.40 | 24.44 | 82.59 | - |
handlebars | 26.59 | 38.56 | 95.62 | - |
jsp | 117.05 | 24.88 | 93.10 | - |
thymeleaf | 138.60 | 25.21 | 89.73 | - |
velocity | 248.15 | 24.91 | 83.98 | - |
v8ejs | 102.65 | 25.37 | 207.70 | 280.90 |
- request/sec (higher is better)
todos:
- more sophisticated bench.sh scripts including browser rendering time.
- more practical templates
- more template engines
- ...
see also:
- https://jira.spring.io/browse/SPR-13795
- https://jira.spring.io/browse/SPR-13508
- https://speakerdeck.com/sdeleuze/isomorphic-templating-with-spring-boot-nashorn-and-react
may the SOURCE be with you...