Skip to content

Commit

Permalink
highlight those above the average
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Apr 27, 2012
1 parent 6cf3e68 commit 116f7ab
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions bm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
var stylus = require('./')
, fs = require('fs');

var times = ~~process.env.TIMES || 1;
var times = ~~process.env.TIMES || 1
, avgs = [];

// test cases

Expand Down Expand Up @@ -46,6 +47,17 @@ cases.forEach(function(test){
return sum + n;
}) / times;

console.log(' \033[36m%s \033[90m%dms\033[0m', name, avg | 0);
avgs.push(avg);

// im cool like that
var avgavg = avgs.reduce(function(sum, n){
return sum + n;
}) / avgs.length;

if (avg > avgavg) {
console.log(' \033[31m%s \033[31m%dms\033[0m', name, avg | 0);
} else {
console.log(' \033[36m%s \033[90m%dms\033[0m', name, avg | 0);
}
});
console.log();

0 comments on commit 116f7ab

Please sign in to comment.