Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-02-12 11:51:53 +0400
committerisaacs <i@izs.me>2013-02-20 02:14:31 +0400
commit3b16657e77511d92b55d1d2157485d8dd0df0c00 (patch)
tree3f384dca46993fc05ee572950a0f1703341c73d7 /benchmark
parent536ce446898f3b788d7f0134de8397db55161b07 (diff)
bench: misc/url
Diffstat (limited to 'benchmark')
-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 fd8f72c6ea3..6c2799b6cb9 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));
}