diff options
author | isaacs <i@izs.me> | 2013-02-13 10:47:29 -0800 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-02-19 14:14:38 -0800 |
commit | 087c43796178733da54bff9e8291a5a312c466f1 (patch) | |
tree | b48c8bab352a5303ae52b5d94cab0ccb5dcecbe2 /benchmark/compare.js | |
parent | 7658f4c29c162819f72219bacf73aa840c1e59e4 (diff) | |
download | node-new-087c43796178733da54bff9e8291a5a312c466f1.tar.gz |
bench: Add --html to compare script
Diffstat (limited to 'benchmark/compare.js')
-rw-r--r-- | benchmark/compare.js | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/benchmark/compare.js b/benchmark/compare.js index 05733a1e37..5b4beda3f1 100644 --- a/benchmark/compare.js +++ b/benchmark/compare.js @@ -1,7 +1,9 @@ -var usage = 'node benchmark/compare.js <node-binary1> <node-binary2>'; +var usage = 'node benchmark/compare.js <node-binary1> <node-binary2> [--html] [--red|-r] [--green|-g]'; var show = 'both'; var nodes = []; +var html = false; + for (var i = 2; i < process.argv.length; i++) { var arg = process.argv[i]; switch (arg) { @@ -11,12 +13,32 @@ for (var i = 2; i < process.argv.length; i++) { case '--green': case '-g': show = show === 'red' ? 'both' : 'green'; break; + case '--html': + html = true; + break; + case '-h': case '-?': case '--help': + console.log(usage); + process.exit(0); default: nodes.push(arg); break; } } +if (!html) { + var start = ''; + var green = '\033[1;32m'; + var red = '\033[1;31m'; + var reset = '\033[m'; + var end = ''; +} else { + var start = '<pre style="background-color:#333;color:#eee">'; + var green = '<span style="background-color:#0f0;color:#000">'; + var red = '<span style="background-color:#f00">'; + var reset = '</span>'; + var end = '</pre>'; +} + var runBench = process.env.NODE_BENCH || 'bench'; if (nodes.length !== 2) @@ -79,11 +101,10 @@ function compare() { // each result is an object with {"foo.js arg=bar":12345,...} // compare each thing, and show which node did the best. // node[0] is shown in green, node[1] shown in red. - var green = '\033[1;32m'; - var red = '\033[1;31m'; - var reset = '\033[m'; var maxLen = -Infinity; var util = require('util'); + console.log(start); + Object.keys(results).map(function(bench) { var res = results[bench]; var n0 = res[nodes[0]]; @@ -113,4 +134,5 @@ function compare() { var dots = ' ' + new Array(Math.max(0, dotLen)).join('.') + ' '; console.log(l + dots + pct); }); + console.log(end); } |