forked from fizzed/template-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
514 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,58 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<name>Template Benchmark</name> | ||
<description>JMH Benchmark of Popular Template Engines</description> | ||
<name>Template Benchmark</name> | ||
<description>JMH Benchmark of Popular Template Engines</description> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.mitchellbosecke</groupId> | ||
<artifactId>template-benchmark</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.mitchellbosecke</groupId> | ||
<artifactId>template-benchmark</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<jmh.version>1.7.1</jmh.version> | ||
<uberjar.name>benchmarks</uberjar.name> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<jmh.version>1.7.1</jmh.version> | ||
<uberjar.name>benchmarks</uberjar.name> | ||
|
||
<pebble.version>1.5.2</pebble.version> | ||
<mustache.version>0.9.0</mustache.version> | ||
<freemarker.version>2.3.22</freemarker.version> | ||
<velocity.version>1.7</velocity.version> | ||
<thymeleaf.version>2.1.4.RELEASE</thymeleaf.version> | ||
<junit.version>4.11</junit.version> | ||
<trimou.version>1.8.1.Final</trimou.version> | ||
<rocker.version>0.9.0</rocker.version> | ||
</properties> | ||
<pebble.version>1.5.2</pebble.version> | ||
<mustache.version>0.9.0</mustache.version> | ||
<freemarker.version>2.3.22</freemarker.version> | ||
<velocity.version>1.7</velocity.version> | ||
<thymeleaf.version>3.0.11.RELEASE</thymeleaf.version> | ||
<junit.version>4.11</junit.version> | ||
<trimou.version>1.8.1.Final</trimou.version> | ||
<rocker.version>1.3.0</rocker.version> | ||
</properties> | ||
|
||
<licenses> | ||
<license> | ||
<name>BSD 3-Clause License</name> | ||
<url>http://opensource.org/licenses/BSD-3-Clause</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
</licenses> | ||
<licenses> | ||
<license> | ||
<name>BSD 3-Clause License</name> | ||
<url>http://opensource.org/licenses/BSD-3-Clause</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
</licenses> | ||
|
||
<developers> | ||
<developer> | ||
<name>Mitchell Bösecke</name> | ||
<email>[email protected]</email> | ||
</developer> | ||
</developers> | ||
<developers> | ||
<developer> | ||
<name>Mitchell Bösecke</name> | ||
<email>[email protected]</email> | ||
</developer> | ||
</developers> | ||
|
||
<build> | ||
<finalName>template-benchmark</finalName> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.2</version> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
</configuration> | ||
</plugin> | ||
<build> | ||
<finalName>template-benchmark</finalName> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.0</version> | ||
<configuration> | ||
<release>11</release> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.fizzed</groupId> | ||
<artifactId>rocker-maven-plugin</artifactId> | ||
<version>${rocker.version}</version> | ||
<!-- <version>${rocker.version}</version>--> | ||
<executions> | ||
<execution> | ||
<id>generate-rocker-templates</id> | ||
|
@@ -67,106 +66,117 @@ | |
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>2.2</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<finalName>${uberjar.name}</finalName> | ||
<transformers> | ||
<transformer | ||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<mainClass>org.openjdk.jmh.Main</mainClass> | ||
</transformer> | ||
</transformers> | ||
<filters> | ||
<filter> | ||
<!-- Shading signed JARs will fail without this. http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar --> | ||
<artifact>*:*</artifact> | ||
<excludes> | ||
<exclude>META-INF/*.SF</exclude> | ||
<exclude>META-INF/*.DSA</exclude> | ||
<exclude>META-INF/*.RSA</exclude> | ||
</excludes> | ||
</filter> | ||
</filters> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>2.2</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<finalName>${uberjar.name}</finalName> | ||
<transformers> | ||
<transformer | ||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<mainClass>org.openjdk.jmh.Main</mainClass> | ||
</transformer> | ||
</transformers> | ||
<filters> | ||
<filter> | ||
<!-- Shading signed JARs will fail without this. http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar --> | ||
<artifact>*:*</artifact> | ||
<excludes> | ||
<exclude>META-INF/*.SF</exclude> | ||
<exclude>META-INF/*.DSA</exclude> | ||
<exclude>META-INF/*.RSA</exclude> | ||
</excludes> | ||
</filter> | ||
</filters> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependencies> | ||
|
||
<!-- benchmarking dependencies --> | ||
<dependency> | ||
<groupId>org.openjdk.jmh</groupId> | ||
<artifactId>jmh-core</artifactId> | ||
<version>${jmh.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openjdk.jmh</groupId> | ||
<artifactId>jmh-generator-annprocess</artifactId> | ||
<version>${jmh.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<!-- benchmarking dependencies --> | ||
<dependency> | ||
<groupId>org.openjdk.jmh</groupId> | ||
<artifactId>jmh-core</artifactId> | ||
<version>${jmh.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openjdk.jmh</groupId> | ||
<artifactId>jmh-generator-annprocess</artifactId> | ||
<version>${jmh.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- template engines --> | ||
<dependency> | ||
<groupId>com.mitchellbosecke</groupId> | ||
<artifactId>pebble</artifactId> | ||
<version>${pebble.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.spullara.mustache.java</groupId> | ||
<artifactId>compiler</artifactId> | ||
<version>${mustache.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.freemarker</groupId> | ||
<artifactId>freemarker</artifactId> | ||
<version>${freemarker.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.velocity</groupId> | ||
<artifactId>velocity</artifactId> | ||
<version>${velocity.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.thymeleaf</groupId> | ||
<artifactId>thymeleaf</artifactId> | ||
<version>${thymeleaf.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.trimou</groupId> | ||
<artifactId>trimou-core</artifactId> | ||
<version>${trimou.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.annotation</groupId> | ||
<artifactId>javax.annotation-api</artifactId> | ||
<version>1.3.1</version> | ||
</dependency> | ||
|
||
<!-- template engines --> | ||
<dependency> | ||
<groupId>com.mitchellbosecke</groupId> | ||
<artifactId>pebble</artifactId> | ||
<version>${pebble.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.spullara.mustache.java</groupId> | ||
<artifactId>compiler</artifactId> | ||
<version>${mustache.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.freemarker</groupId> | ||
<artifactId>freemarker</artifactId> | ||
<version>${freemarker.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.velocity</groupId> | ||
<artifactId>velocity</artifactId> | ||
<version>${velocity.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.thymeleaf</groupId> | ||
<artifactId>thymeleaf</artifactId> | ||
<version>${thymeleaf.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.trimou</groupId> | ||
<artifactId>trimou-core</artifactId> | ||
<version>${trimou.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fizzed</groupId> | ||
<artifactId>rocker-runtime</artifactId> | ||
<version>${rocker.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>sukhvir41</groupId> | ||
<artifactId>HtmlTemplate</artifactId> | ||
<version>12.0</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
<version>${junit.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
<version>${junit.version}</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
</dependencies> | ||
|
||
<scm> | ||
<connection>scm:git:git://github.com/mbosecke/template-benchmark.git</connection> | ||
<developerConnection>scm:git:[email protected]:mbosecke/template-benchmark.git</developerConnection> | ||
<url>http://github.com/mbosecke/template-benchmark</url> | ||
</scm> | ||
<scm> | ||
<connection>scm:git:git://github.com/mbosecke/template-benchmark.git</connection> | ||
<developerConnection>scm:git:[email protected]:mbosecke/template-benchmark.git</developerConnection> | ||
<url>http://github.com/mbosecke/template-benchmark</url> | ||
</scm> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
"Benchmark","Mode","Threads","Samples","Score","Score Error (99.9%)","Unit" | ||
"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" | ||
"com.mitchellbosecke.benchmark.Freemarker.benchmark","thrpt",1,50.000000,19052.955591,79.174623,"ops/s" | ||
"com.mitchellbosecke.benchmark.HtmlTemplate.benchmark","thrpt",1,50.000000,28981.551040,113.049542,"ops/s" | ||
"com.mitchellbosecke.benchmark.Mustache.benchmark","thrpt",1,50.000000,28363.275059,308.670742,"ops/s" | ||
"com.mitchellbosecke.benchmark.Pebble.benchmark","thrpt",1,50.000000,26108.345156,203.361253,"ops/s" | ||
"com.mitchellbosecke.benchmark.Rocker.benchmark","thrpt",1,50.000000,46169.288915,189.579794,"ops/s" | ||
"com.mitchellbosecke.benchmark.Thymeleaf.benchmark","thrpt",1,50.000000,4723.666887,46.583253,"ops/s" | ||
"com.mitchellbosecke.benchmark.Trimou.benchmark","thrpt",1,50.000000,21545.698088,176.550664,"ops/s" | ||
"com.mitchellbosecke.benchmark.Velocity.benchmark","thrpt",1,50.000000,19416.760785,55.580911,"ops/s" |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/mitchellbosecke/benchmark/HtmlTemplate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.mitchellbosecke.benchmark; | ||
|
||
import com.github.sukhvir41.core.settings.SettingOptions; | ||
import com.github.sukhvir41.core.settings.SettingsManager; | ||
import com.github.sukhvir41.template.HtmlTemplateLoader; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.Setup; | ||
|
||
import java.nio.file.Paths; | ||
import java.util.Map; | ||
|
||
public class HtmlTemplate extends BaseBenchmark { | ||
|
||
private com.github.sukhvir41.template.HtmlTemplate htmlTemplate; | ||
|
||
@Setup | ||
public void setup() throws Exception { | ||
//System.out.println(this.getClass().getClassLoader().getResource("templates/stocks.HtTemplate.html").toURI()); | ||
htmlTemplate = HtmlTemplateLoader.load( | ||
Paths.get("D:\\sharedFolder\\template-benchmark\\stocks.HtTemplate.html"), | ||
//Paths.get(this.getClass().getClassLoader().getResource("templates/stocks.HtTemplate.html").toURI()), | ||
SettingsManager.load(Map.of(SettingOptions.SUPPRESS_EXCEPTIONS, false)) | ||
); | ||
} | ||
|
||
@Benchmark | ||
public String benchmark() { | ||
return htmlTemplate.render(getContext()); | ||
} | ||
} |
Oops, something went wrong.