- haml.js x 724,557 ops/sec ±4.68% (74 runs sampled)
- hogan.js x 11,141,376 ops/sec ±3.76% (82 runs sampled)
- pug x 4,055,327 ops/sec ±4.10% (77 runs sampled)
- ejs x 338,938 ops/sec ±4.29% (78 runs sampled)
Last active
April 17, 2016 02:23
-
-
Save AGhost-7/9025111460e42c73c6b9d2173657626a to your computer and use it in GitHub Desktop.
Bechmark for various templates
This file contains hidden or 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
| /* jshint esversion: 6 */ | |
| const Benchmark = require('benchmark'); | |
| const haml = require('hamljs'); | |
| const hogan = require('hogan.js'); | |
| const pug = require('pug'); | |
| const ejs = require('ejs'); | |
| const suite = new Benchmark.Suite(); | |
| suite | |
| .add('haml.js', () => { | |
| const h = haml.compile('%p hello #{name}'); | |
| return () => { | |
| h({ name: 'foobar' }); | |
| }; | |
| }()) | |
| .add('hogan.js', () => { | |
| const h = hogan.compile('<p>hello {{name}}</p>'); | |
| return () => { | |
| h.render({ name: 'foobar' }); | |
| }; | |
| }()) | |
| .add('pug', () => { | |
| const h = pug.compile('p hello #{name}'); | |
| return () => { | |
| h({ name: 'foobar' }); | |
| }; | |
| }()) | |
| .add('ejs', () => { | |
| const h = ejs.compile('<p>hello <%= name %></p>'); | |
| return () => { | |
| h({ name: 'foobar' }); | |
| }; | |
| }()) | |
| .on('cycle', (event) => { | |
| console.log(String(event.target)); | |
| }) | |
| .on('complete', function() { | |
| console.log('Winner is:', this.filter('fastest').map('name')); | |
| }) | |
| .run({ async: true }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment