Permalink
Browse files

Added `make benchmark` for continuous-bench

  • Loading branch information...
1 parent 623184d commit 4523886115417f16cc514deb632232691fec7564 @tj tj committed Aug 20, 2011
View
@@ -11,11 +11,7 @@ test:
$(TESTS)
benchmark:
- @node benchmarks/jade.js \
- && node benchmarks/jade-self.js \
- && node benchmarks/haml.js \
- && node benchmarks/haml2.js \
- && node benchmarks/ejs.js
+ @node support/benchmark
jade.js: $(SRC)
@node support/compile.js $^
View
@@ -1,32 +0,0 @@
-
-/**
- * Module dependencies.
- */
-
-var sys = require('sys');
-
-var currentLabel,
- startTime;
-
-exports.times = 2000;
-
-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;
- sys.print(duration + ' ms\n');
-};
-
-exports.locals = {
- one: 'one',
- two: 'two',
- three: 'three',
- items: Array(200).join('test ').split(' ')
-};
-
-console.log('\nbenchmarking %d times\n', exports.times);
Submodule ejs deleted from 8afd48
View
@@ -1,24 +0,0 @@
-
-/**
- * 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();
@@ -1,6 +0,0 @@
-ul
- li!= self.one
- li!= self.two
- li!= self.three
- - each item in self.items
- li!= item
View
@@ -1,8 +0,0 @@
-<ul>
- <li><%- one %></li>
- <li><%- two %></li>
- <li><%- three %></li>
- <% items.forEach(function(item){ %>
- <li><%- item %></li>
- <% }) %>
-</ul>
View
@@ -1,6 +0,0 @@
-%ul
- %li= one
- %li= two
- %li= three
- :each item in items
- %li= item
View
@@ -1,6 +0,0 @@
-ul
- li!= one
- li!= two
- li!= three
- - each item in items
- li!= item
View
@@ -1,6 +0,0 @@
-%ul
- %li!= one
- %li!= two
- %li!= three
- - each item in items
- %li!= item
Submodule haml deleted from 382bc1
Submodule haml-js deleted from 34fb09
View
@@ -1,25 +0,0 @@
-
-/**
- * Module dependencies.
- */
-
-var bm = require('./common'),
- haml = require('./haml-js/lib/haml'),
- fs = require('fs');
-
-var str = fs.readFileSync(__dirname + '/example.haml', 'ascii');
-
-var n = bm.times;
-bm.start('haml-js compilation');
-while (n--) {
- haml(str);
-}
-bm.stop();
-
-var n = bm.times;
-var fn = haml(str);
-bm.start('haml-js execution');
-while (n--) {
- fn.call('whatever scope', bm.locals);
-}
-bm.stop();
View
@@ -1,30 +0,0 @@
-
-/**
- * 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();
View
@@ -1,43 +0,0 @@
-
-/**
- * Module dependencies.
- */
-
-var bm = require('./common'),
- jade = require('../lib/jade'),
- fs = require('fs');
-
-var str = fs.readFileSync(__dirname + '/example-self.jade', 'ascii');
-var fn = jade.compile(str, { self: true });
-var n = bm.times;
-
-bm.start('jade self compilation');
-while (n--) {
- jade.render(str, {
- filename: 'example-self.jade'
- , self: true
- , locals: bm.locals
- });
-}
-bm.stop();
-
-var n = bm.times;
-
-bm.start('jade self execution');
-while (n--) {
- jade.render(str, {
- filename: 'example-self.jade'
- , self: true
- , cache: true
- , locals: bm.locals
- });
-}
-bm.stop();
-
-var n = bm.times;
-
-bm.start('jade compile()');
-while (n--) {
- fn(bm.locals);
-}
-bm.stop();
View
@@ -1,41 +0,0 @@
-
-/**
- * Module dependencies.
- */
-
-var bm = require('./common'),
- jade = require('../lib/jade'),
- fs = require('fs');
-
-var str = fs.readFileSync(__dirname + '/example.jade', 'ascii');
-var fn = jade.compile(str);
-var n = bm.times;
-
-bm.start('jade compilation');
-while (n--) {
- jade.render(str, {
- filename: 'example.jade',
- locals: bm.locals
- });
-}
-bm.stop();
-
-var n = bm.times;
-
-bm.start('jade execution');
-while (n--) {
- jade.render(str, {
- filename: 'example.jade',
- cache: true,
- locals: bm.locals
- });
-}
-bm.stop();
-
-var n = bm.times;
-
-bm.start('jade compile()');
-while (n--) {
- fn(bm.locals);
-}
-bm.stop();
View
@@ -12,7 +12,8 @@
"sass": ">= 0.0.1",
"less": ">= 0.0.1",
"markdown": ">= 0.0.1",
- "stylus": ">= 0.0.1"
+ "stylus": ">= 0.0.1",
+ "uubench": "0.0.1"
},
"scripts" : { "prepublish" : "npm prune" },
"engines": { "node": ">= 0.1.98" }
View
@@ -0,0 +1,62 @@
+
+/**
+ * Module dependencies.
+ */
+
+var uubench = require('uubench')
+ , jade = require('../');
+
+
+var suite = new uubench.Suite({
+ min: 200,
+ result: function(name, stats){
+ var persec = 1000 / stats.elapsed
+ , ops = stats.iterations * persec;
+ console.log('%s: %d', name, ops | 0);
+ }
+});
+
+var str = 'html\n body\n h1 Title'
+ , fn = jade.compile(str);
+
+suite.bench('tiny', function(next){
+ fn();
+ next();
+});
+
+str = '\
+html\n\
+ body\n\
+ h1 Title\n\
+ ul#menu\n\
+ li: a(href="#") Home\n\
+ li: a(href="#") About Us\n\
+ li: a(href="#") Store\n\
+ li: a(href="#") FAQ\n\
+ li: a(href="#") Contact\n\
+';
+
+var fn2 = jade.compile(str);
+
+suite.bench('small', function(next){
+ fn2();
+ next();
+});
+
+str = '\
+html\n\
+ body\n\
+ h1 #{title}\n\
+ ul#menu\n\
+ - each link in links\r\n\
+ li: a(href="#")= link\r\n\
+';
+
+var fn3 = jade.compile(str);
+
+suite.bench('small locals', function(next){
+ fn3({ title: 'Title', links: ['Home', 'About Us', 'Store', 'FAQ', 'Contact'] });
+ next();
+});
+
+suite.run();

0 comments on commit 4523886

Please sign in to comment.