Skip to content

Commit

Permalink
Added my old haml.js to the benchmarks
Browse files Browse the repository at this point in the history
Jade needs some optimization :)
  • Loading branch information
tj committed Aug 26, 2010
1 parent 53e8c9f commit 074b722
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "benchmarks/ejs"]
path = benchmarks/ejs
url = git://github.com/visionmedia/ejs.git
[submodule "benchmarks/haml"]
path = benchmarks/haml
url = git://github.com/visionmedia/haml.js.git
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ api.html: lib/jade.js
benchmark:
@node benchmarks/jade.js && \
node benchmarks/haml.js && \
node benchmarks/haml2.js && \
node benchmarks/ejs.js

.PHONY: install uninstall test example benchmark
6 changes: 6 additions & 0 deletions benchmarks/example2.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
%ul
%li!= one
%li!= two
%li!= three
- each item in items
%li!= item
1 change: 1 addition & 0 deletions benchmarks/haml
Submodule haml added at 382bc1
4 changes: 2 additions & 2 deletions benchmarks/haml.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ var bm = require('./common'),
var str = fs.readFileSync(__dirname + '/example.haml', 'ascii');

var n = bm.times;
bm.start('haml compilation');
bm.start('haml-js compilation');
while (n--) {
haml(str);
}
bm.stop();

var n = bm.times;
var fn = haml(str);
bm.start('haml execution');
bm.start('haml-js execution');
while (n--) {
fn.call('whatever scope', bm.locals);
}
Expand Down
30 changes: 30 additions & 0 deletions benchmarks/haml2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

/**
* Module dependencies.
*/

var bm = require('./common'),
haml = require('./haml/lib/haml'),
fs = require('fs');

var str = fs.readFileSync(__dirname + '/example2.haml', 'ascii');

var n = bm.times;
bm.start('haml compilation');
while (n--) {
haml.render(str, {
locals: bm.locals
});
}
bm.stop();

var n = bm.times;
bm.start('haml execution');
while (n--) {
haml.render(str, {
locals: bm.locals,
cache: true,
filename: 'example2.haml'
});
}
bm.stop();

0 comments on commit 074b722

Please sign in to comment.