Skip to content

Instantly share code, notes, and snippets.

@chowey
Created February 23, 2012 14:37
Show Gist options
  • Save chowey/1893116 to your computer and use it in GitHub Desktop.
Save chowey/1893116 to your computer and use it in GitHub Desktop.
Benchmark Multiline Stylus
var stylus1 = require('../node_modules/stylus'),
stylus2 = require('../cloned/stylus'),
Benchmark = require('benchmark'),
fs = require('fs');
fs.readFile('C:/node/cloned/stylus/test/cases/regression.127.styl', 'utf8', function (err, str) {
if (err) throw err;
var handler = function (err, css) {
if (err) console.error(err);
};
var suite = new Benchmark.Suite;
suite.add('Stylus (original)', function () {
stylus1(str, {filename: 'regression.127.styl'}, handler);
})
.add('Stylus (modified)', function () {
stylus2(str, {filename: 'regression.127.styl'}, handler);
})
.on('cycle', function (event, bench) {
console.log(bench.toString());
})
.on('complete', function () {
console.log('Fastest is ' + this.filter('fastest').pluck('name'));
})
.run();
});
c:\node\test>node bench
Stylus (original) x 273,162 ops/sec ±0.60% (58 runs sampled)
Stylus (modified) x 277,525 ops/sec ±1.19% (60 runs sampled)
Fastest is Stylus (original),Stylus (modified)
@chowey
Copy link
Author

chowey commented Feb 23, 2012

Also, using control.boilerplate.styl gives the following results:

c:\node\test>node bench
Stylus (original) x 270,123 ops/sec ±0.91% (62 runs sampled)
Stylus (modified) x 281,184 ops/sec ±0.19% (58 runs sampled)
Fastest is Stylus (original),Stylus (modified)

@chowey
Copy link
Author

chowey commented Feb 23, 2012

The modified code is 1.6% slower for regression.127.styl and 4.1% slower for control.boilerplate.styl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment