summaryrefslogtreecommitdiff
path: root/benchmark/url/url-resolve.js
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2017-02-09 23:42:14 +0800
committerJames M Snell <jasnell@gmail.com>2017-02-15 09:12:30 -0800
commit7ee95045dd9ed5968792aec9c12b6b0054368dc6 (patch)
tree5b4fdfeb0aacfad2bb5088dbcc3ce55ad06bd76f /benchmark/url/url-resolve.js
parentd8ac08a62a44c07fd4b46276ba2365870654a3b5 (diff)
downloadandroid-node-v8-7ee95045dd9ed5968792aec9c12b6b0054368dc6.tar.gz
android-node-v8-7ee95045dd9ed5968792aec9c12b6b0054368dc6.tar.bz2
android-node-v8-7ee95045dd9ed5968792aec9c12b6b0054368dc6.zip
benchmark: clean up legacy url benchmarks
PR-URL: https://github.com/nodejs/node/pull/11264 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
Diffstat (limited to 'benchmark/url/url-resolve.js')
-rw-r--r--benchmark/url/url-resolve.js40
1 files changed, 16 insertions, 24 deletions
diff --git a/benchmark/url/url-resolve.js b/benchmark/url/url-resolve.js
index 8372132e4d..4335511ca6 100644
--- a/benchmark/url/url-resolve.js
+++ b/benchmark/url/url-resolve.js
@@ -1,36 +1,28 @@
'use strict';
-var common = require('../common.js');
-var url = require('url');
-var v8 = require('v8');
+const common = require('../common.js');
+const url = require('url');
+const v8 = require('v8');
+const hrefs = require('../fixtures/url-inputs.js').urls;
+hrefs.noscheme = 'some.ran/dom/url.thing?oh=yes#whoo';
-var hrefs = [
- 'http://example.com/',
- 'http://nodejs.org/docs/latest/api/url.html#url_url_format_urlobj',
- 'http://blog.nodejs.org/',
- 'https://encrypted.google.com/search?q=url&q=site:npmjs.org&hl=en',
- 'javascript:alert("node is awesome");',
- 'some.ran/dom/url.thing?oh=yes#whoo'
-];
+const paths = {
+ 'up': '../../../../../etc/passwd',
+ 'sibling': '../foo/bar?baz=boom',
+ 'foo/bar': 'foo/bar',
+ 'withscheme': 'http://nodejs.org',
+ 'down': './foo/bar?baz'
+};
-
-var paths = [
- '../../../../../etc/passwd',
- '../foo/bar?baz=boom',
- 'foo/bar',
- 'http://nodejs.org',
- './foo/bar?baz'
-];
-
-var bench = common.createBenchmark(main, {
+const bench = common.createBenchmark(main, {
href: Object.keys(hrefs),
path: Object.keys(paths),
n: [1e5]
});
function main(conf) {
- var n = conf.n | 0;
- var href = hrefs[conf.href];
- var path = paths[conf.path];
+ const n = conf.n | 0;
+ const href = hrefs[conf.href];
+ const path = paths[conf.path];
// Force-optimize url.resolve() so that the benchmark doesn't get
// disrupted by the optimizer kicking in halfway through.