Skip to content

Commit

Permalink
Added unit tests; updated results examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jjlauer committed Sep 18, 2015
1 parent a114da7 commit 438f27b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 17 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ JMH benchmark for popular Java template engines:
* [Freemarker](http://freemarker.org/)
* [Mustache](https://github.com/spullara/mustache.java)
* [Pebble](http://www.mitchellbosecke.com/pebble)
* [Rocker](https://github.com/fizzed/rocker)
* [Thymeleaf](http://www.thymeleaf.org/)
* [Velocity](http://velocity.apache.org/)
* [Trimou](http://trimou.org/)
* [Velocity](http://velocity.apache.org/)

Running the benchmark
======================
Expand Down
13 changes: 7 additions & 6 deletions results.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"Benchmark","Mode","Threads","Samples","Score","Score Error (99.9%)","Unit"
"com.mitchellbosecke.benchmark.Freemarker.benchmark","thrpt",1,50.000000,14173.537437,201.522006,"ops/s"
"com.mitchellbosecke.benchmark.Mustache.benchmark","thrpt",1,50.000000,21267.606717,201.562280,"ops/s"
"com.mitchellbosecke.benchmark.Pebble.benchmark","thrpt",1,50.000000,30057.760185,297.532402,"ops/s"
"com.mitchellbosecke.benchmark.Thymeleaf.benchmark","thrpt",1,50.000000,915.754702,20.384273,"ops/s"
"com.mitchellbosecke.benchmark.Trimou.benchmark","thrpt",1,50.000000,16089.653704,197.984211,"ops/s"
"com.mitchellbosecke.benchmark.Velocity.benchmark","thrpt",1,50.000000,18930.770276,297.552843,"ops/s"
"com.mitchellbosecke.benchmark.Freemarker.benchmark","thrpt",1,50.000000,16737.333340,184.040944,"ops/s"
"com.mitchellbosecke.benchmark.Mustache.benchmark","thrpt",1,50.000000,23393.115757,159.003408,"ops/s"
"com.mitchellbosecke.benchmark.Pebble.benchmark","thrpt",1,50.000000,35736.995844,248.860050,"ops/s"
"com.mitchellbosecke.benchmark.Rocker.benchmark","thrpt",1,50.000000,41123.645420,191.949947,"ops/s"
"com.mitchellbosecke.benchmark.Thymeleaf.benchmark","thrpt",1,50.000000,1519.092213,18.156292,"ops/s"
"com.mitchellbosecke.benchmark.Trimou.benchmark","thrpt",1,50.000000,19081.925071,112.440326,"ops/s"
"com.mitchellbosecke.benchmark.Velocity.benchmark","thrpt",1,50.000000,21553.362499,223.035824,"ops/s"
Binary file modified results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions src/main/java/com/mitchellbosecke/benchmark/Rocker.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.mitchellbosecke.benchmark;

import com.mitchellbosecke.benchmark.BaseBenchmark;
import com.mitchellbosecke.benchmark.model.Stock;
import freemarker.cache.ClassTemplateLoader;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Setup;

import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.List;
import java.util.Map;

/**
* Benchmark for Rocker template engine by Fizzed.
*
* https://github.com/fizzed/rocker
*
* @author joelauer
*/
public class Rocker extends BaseBenchmark {

private List<Stock> items;
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/templates/stocks.rocker.raw
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ thead {
</thead>
<tbody>
@for ((ForIterator i, Stock item) : items) {
<tr class="@if (i.index() % 2 == 0) {even} else {odd}">
<td>@i.index()</td>
<tr class="@if (i.index() % 2 == 0) {odd} else {even}">
<td>@Integer.toString(i.index()+1)</td>
<td><a href="/stocks/@item.getSymbol()">@item.getSymbol()</a></td>
<td><a href="@item.getUrl()">@item.getName()</a></td>
<td><strong>item.getPrice()</strong></td>@if (item.getChange() < 0.0) {
<td><strong>@item.getPrice()</strong></td>@if (item.getChange() < 0.0) {
<td class="minus">@item.getChange()</td>
<td class="minus">@item.getRatio()</td>} else {
<td>@item.getChange()</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ public void testFreemarkerOutput() throws IOException, TemplateException {
freemarker.setup();
assertOutput(freemarker.benchmark());
}

@Test
public void testRockerOutput() throws IOException, TemplateException {
Rocker rocker = new Rocker();
rocker.setup();
assertOutput(rocker.benchmark());
}

@Test
public void testPebbleOutput() throws IOException, PebbleException {
Expand Down

0 comments on commit 438f27b

Please sign in to comment.