Skip to content

Commit

Permalink
benchmark: clean up legacy url benchmarks
Browse files Browse the repository at this point in the history
PR-URL: #11264
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
  • Loading branch information
joyeecheung authored and jasnell committed Feb 15, 2017
1 parent d8ac08a commit 7ee9504
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 80 deletions.
15 changes: 1 addition & 14 deletions benchmark/querystring/querystring-parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
11 changes: 6 additions & 5 deletions benchmark/url/url-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ 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]
});

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
Expand Down
37 changes: 0 additions & 37 deletions benchmark/url/url-parse.js

This file was deleted.

40 changes: 16 additions & 24 deletions benchmark/url/url-resolve.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit 7ee9504

Please sign in to comment.