summaryrefslogtreecommitdiff
path: root/benchmark
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
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')
-rw-r--r--benchmark/querystring/querystring-parse.js15
-rw-r--r--benchmark/url/url-format.js11
-rw-r--r--benchmark/url/url-parse.js37
-rw-r--r--benchmark/url/url-resolve.js40
4 files changed, 23 insertions, 80 deletions
diff --git a/benchmark/querystring/querystring-parse.js b/benchmark/querystring/querystring-parse.js
index 0ed6777512..a44c3879bd 100644
--- a/benchmark/querystring/querystring-parse.js
+++ b/benchmark/querystring/querystring-parse.js
@@ -2,20 +2,7 @@
var common = require('../common.js');
var querystring = require('querystring');
var v8 = require('v8');
-
-var inputs = {
- noencode: 'foo=bar&baz=quux&xyzzy=thud',
- multicharsep: 'foo=bar&&&&&&&&&&baz=quux&&&&&&&&&&xyzzy=thud',
- encodefake: 'foo=%©ar&baz=%A©uux&xyzzy=%©ud',
- encodemany: '%66%6F%6F=bar&%62%61%7A=quux&xyzzy=%74h%75d',
- encodelast: 'foo=bar&baz=quux&xyzzy=thu%64',
- multivalue: 'foo=bar&foo=baz&foo=quux&quuy=quuz',
- multivaluemany: 'foo=bar&foo=baz&foo=quux&quuy=quuz&foo=abc&foo=def&' +
- 'foo=ghi&foo=jkl&foo=mno&foo=pqr&foo=stu&foo=vwxyz',
- manypairs: 'a&b&c&d&e&f&g&h&i&j&k&l&m&n&o&p&q&r&s&t&u&v&w&x&y&z',
- manyblankpairs: '&&&&&&&&&&&&&&&&&&&&&&&&',
- altspaces: 'foo+bar=baz+quux&xyzzy+thud=quuy+quuz&abc=def+ghi'
-};
+var inputs = require('../fixtures/url-inputs.js').searchParams;
var bench = common.createBenchmark(main, {
type: Object.keys(inputs),
diff --git a/benchmark/url/url-format.js b/benchmark/url/url-format.js
index 3f7df8a0bc..886958406b 100644
--- a/benchmark/url/url-format.js
+++ b/benchmark/url/url-format.js
@@ -3,8 +3,13 @@ const common = require('../common.js');
const url = require('url');
const v8 = require('v8');
+const inputs = {
+ slashes: {slashes: true, host: 'localhost'},
+ file: {protocol: 'file:', pathname: '/foo'},
+};
+
const bench = common.createBenchmark(main, {
- type: 'one two'.split(' '),
+ type: Object.keys(inputs),
n: [25e6]
});
@@ -12,10 +17,6 @@ function main(conf) {
const type = conf.type;
const n = conf.n | 0;
- const inputs = {
- one: {slashes: true, host: 'localhost'},
- two: {protocol: 'file:', pathname: '/foo'},
- };
const input = inputs[type] || '';
// Force-optimize url.format() so that the benchmark doesn't get
diff --git a/benchmark/url/url-parse.js b/benchmark/url/url-parse.js
deleted file mode 100644
index 89679548b8..0000000000
--- a/benchmark/url/url-parse.js
+++ /dev/null
@@ -1,37 +0,0 @@
-'use strict';
-var common = require('../common.js');
-var url = require('url');
-var v8 = require('v8');
-
-var bench = common.createBenchmark(main, {
- type: 'one two three four five six'.split(' '),
- n: [25e4]
-});
-
-function main(conf) {
- var type = conf.type;
- var n = conf.n | 0;
-
- var inputs = {
- one: 'http://nodejs.org/docs/latest/api/url.html#url_url_format_urlobj',
- two: 'http://blog.nodejs.org/',
- three: 'https://encrypted.google.com/search?q=url&q=site:npmjs.org&hl=en',
- four: 'javascript:alert("node is awesome");',
- five: 'some.ran/dom/url.thing?oh=yes#whoo',
- six: 'https://user:pass@example.com/',
- };
- var input = inputs[type] || '';
-
- // Force-optimize url.parse() so that the benchmark doesn't get
- // disrupted by the optimizer kicking in halfway through.
- for (var name in inputs)
- url.parse(inputs[name]);
-
- v8.setFlagsFromString('--allow_natives_syntax');
- eval('%OptimizeFunctionOnNextCall(url.parse)');
-
- bench.start();
- for (var i = 0; i < n; i += 1)
- url.parse(input);
- bench.end(n);
-}
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.