diff options
author | isaacs <i@izs.me> | 2013-02-11 23:51:53 -0800 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-02-19 14:14:31 -0800 |
commit | 3b16657e77511d92b55d1d2157485d8dd0df0c00 (patch) | |
tree | 3f384dca46993fc05ee572950a0f1703341c73d7 | |
parent | 536ce446898f3b788d7f0134de8397db55161b07 (diff) | |
download | nodejs-3b16657e77511d92b55d1d2157485d8dd0df0c00.tar.gz nodejs-3b16657e77511d92b55d1d2157485d8dd0df0c00.tar.bz2 nodejs-3b16657e77511d92b55d1d2157485d8dd0df0c00.zip |
bench: misc/url
-rw-r--r-- | benchmark/misc/url.js (renamed from benchmark/url.js) | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/benchmark/url.js b/benchmark/misc/url.js index fd8f72c6e..6c2799b6c 100644 --- a/benchmark/url.js +++ b/benchmark/misc/url.js @@ -1,5 +1,5 @@ -var util = require('util'); var url = require('url') +var n = 25 * 100; var urls = [ 'http://nodejs.org/docs/latest/api/url.html#url_url_format_urlobj', @@ -18,16 +18,15 @@ var paths = [ benchmark('parse()', url.parse); benchmark('format()', url.format); - paths.forEach(function(p) { - benchmark('resolve("' + p + '")', function(u) { url.resolve(u, p) }); + benchmark('resolve("' + p + '")', function(u) { + url.resolve(u, p) + }); }); function benchmark(name, fun) { - process.stdout.write('benchmarking ' + name + ' ... '); - var timestamp = process.hrtime(); - for (var i = 0; i < 25 * 1000; ++i) { + for (var i = 0; i < n; ++i) { for (var j = 0, k = urls.length; j < k; ++j) fun(urls[j]); } timestamp = process.hrtime(timestamp); @@ -35,6 +34,7 @@ function benchmark(name, fun) { var seconds = timestamp[0]; var nanos = timestamp[1]; var time = seconds + nanos / 1e9; + var rate = n / time; - process.stdout.write(util.format('%s sec\n', time.toFixed(3))); + console.log('misc/url.js %s: %s', name, rate.toPrecision(5)); } |