Skip to content

This project is a benchmark designed to evaluate the performance of various JavaScript template engines. It allows developers to compare rendering performance of several popular template engines in various scenarios

Notifications You must be signed in to change notification settings

itsarnaud/template-engine-bench

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Template Engine Benchmark

This project is a benchmark designed to evaluate the performance of various JavaScript template engines. It allows developers to compare rendering performance of several popular template engines in various scenarios.

How to use ?

1. Clone this repo on your machine:

git clone https://github.com/itsarnaud/templating-engine-bench.git

2. Install dependencies:

npm install

3. Launch the benchmark by executing:

node main.js

4. Results:
Once the benchmark is completed, the results will be automatically updated in the readme file.

Current results

The tests were carried out on:

  • Node v21.7.2
  • MacBook Air M2, 15-inch with 16GB of RAM (2023)

RENDER

friends (runned 5000 times)

pug => 459ms
igodust => 513ms
eta => 604ms
handlebars => 1193ms
ejs => 4670ms
liquidjs => 15967ms

if-expression (runned 5000 times)

pug => 5ms
igodust => 8ms
liquidjs => 93ms
eta => 153ms
ejs => 212ms

projects-escaped (runned 5000 times)

igodust => 38ms
handlebars => 42ms
pug => 122ms
liquidjs => 163ms
eta => 175ms
ejs => 276ms

projects-unescaped (runned 5000 times)

igodust => 8ms
handlebars => 41ms
pug => 122ms
liquidjs => 160ms
eta => 176ms
ejs => 263ms

search-results (runned 5000 times)

igodust => 15ms
pug => 55ms
handlebars => 151ms
eta => 225ms
ejs => 749ms
liquidjs => 1475ms

simple-0 (runned 5000 times)

pug => 1ms
igodust => 4ms
handlebars => 9ms
liquidjs => 17ms
eta => 126ms
ejs => 133ms

simple-1 (runned 5000 times)

pug => 7ms
igodust => 11ms
handlebars => 23ms
liquidjs => 117ms
eta => 160ms
ejs => 258ms

simple-2 (runned 5000 times)

pug => 7ms
igodust => 9ms
handlebars => 16ms
liquidjs => 106ms
eta => 155ms
ejs => 238ms

Adding a new Template Engine

To add a new template engine to this project, follow these simple steps:

1. Create a file for the template engine:
In the engines directory, create a new file named after your template engine, for example my-engine.js. Take a look at the files already created for the syntax.

engines
 ├── igodust.js
 ├── my-engine.js
 └── ...

⚠️ WARNING: Asynchronous rendering methods, such as those returning Promises, are not supported by the benchmarking tool at the moment. Ensure that your rendering method is synchronous to work with the benchmarking tool effectively. ⚠️

2. Add test templates:
Place your template files in the templates directory, following the existing structure. Each test group should have a data file (.js or .json) and template files for each template engine you want to include in the benchmark.

templates
 ├── group1
 │   ├── data.js (or json)
 │   ├── template.dust
 │   ├── template.my-engine
 │   └── ...
 └── ...

And that's it, all you have to do is launch the benchmark!

PRs are welcome 😃❤️

About

This project is a benchmark designed to evaluate the performance of various JavaScript template engines. It allows developers to compare rendering performance of several popular template engines in various scenarios

Topics

Resources

Stars

Watchers

Forks