Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added ejs benchmarks

  • Loading branch information...
commit 6e196f39f3b7c1563e90f35645a054713446fb48 1 parent 36d3d72
@tj tj authored
View
3  .gitmodules
@@ -10,3 +10,6 @@
[submodule "benchmarks/haml-js"]
path = benchmarks/haml-js
url = git://github.com/creationix/haml-js.git
+[submodule "benchmarks/ejs"]
+ path = benchmarks/ejs
+ url = git://github.com/visionmedia/ejs.git
View
3  Makefile
@@ -24,6 +24,7 @@ api.html: lib/jade.js
benchmark:
@node benchmarks/jade.js && \
- node benchmarks/haml.js
+ node benchmarks/haml.js && \
+ node benchmarks/ejs.js
.PHONY: install uninstall test example benchmark
View
9 benchmarks/common.js
@@ -1,4 +1,10 @@
+/**
+ * Module dependencies.
+ */
+
+var sys = require('sys');
+
var currentLabel,
startTime;
@@ -7,12 +13,13 @@ exports.times = 5000;
exports.start = function(label){
currentLabel = label;
startTime = new Date;
+ sys.print(' - \x1b[33m' + currentLabel + '\x1b[0m: ');
};
exports.stop = function(){
var stopTime = new Date,
duration = stopTime - startTime;
- console.log('%s: %dms', currentLabel, duration);
+ sys.print(duration + ' ms\n');
};
exports.locals = {
1  benchmarks/ejs
@@ -0,0 +1 @@
+Subproject commit 56f5ea06d57273c54b666ce557200aeb552009c7
View
24 benchmarks/ejs.js
@@ -0,0 +1,24 @@
+
+/**
+ * Module dependencies.
+ */
+
+var bm = require('./common'),
+ ejs = require('./ejs/lib/ejs'),
+ fs = require('fs');
+
+var str = fs.readFileSync(__dirname + '/example.ejs', 'ascii');
+
+var n = bm.times;
+bm.start('ejs compilation');
+while (n--) {
+ ejs.render(str, { locals: bm.locals });
+}
+bm.stop();
+
+var n = bm.times;
+bm.start('ejs execution');
+while (n--) {
+ ejs.render(str, { locals: bm.locals, cache: true, filename: 'example.ejs' });
+}
+bm.stop();
View
8 benchmarks/example.ejs
@@ -0,0 +1,8 @@
+<ul>
+ <li><%- one %></li>
+ <li><%- two %></li>
+ <li><%- three %></li>
+ <% items.forEach(function(item){ %>
+ <li><%- item %></li>
+ <% }) %>
+</ul>
Please sign in to comment.
Something went wrong with that request. Please try again.