From 6b2af5f0c7056fc8ab35633b45d6346ab2fdc4f5 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 19 Dec 2014 23:44:19 +0100 Subject: benchmark: rename url.parse() benchmark Rename the url.parse() benchmark from url.js to url-parse.js. A follow-up commit is going to add another one for url.resolve(). PR-URL: https://github.com/iojs/io.js/pull/184 Reviewed-By: Chris Dickinson --- benchmark/url/url-parse.js | 36 ++++++++++++++++++++++++++++++++++++ benchmark/url/url.js | 36 ------------------------------------ 2 files changed, 36 insertions(+), 36 deletions(-) create mode 100644 benchmark/url/url-parse.js delete mode 100644 benchmark/url/url.js (limited to 'benchmark/url') diff --git a/benchmark/url/url-parse.js b/benchmark/url/url-parse.js new file mode 100644 index 00000000000..ffa47c4ccd6 --- /dev/null +++ b/benchmark/url/url-parse.js @@ -0,0 +1,36 @@ +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.js b/benchmark/url/url.js deleted file mode 100644 index ffa47c4ccd6..00000000000 --- a/benchmark/url/url.js +++ /dev/null @@ -1,36 +0,0 @@ -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); -} -- cgit v1.2.3