summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorTimothy Gu <timothygu99@gmail.com>2017-02-19 16:51:40 -0800
committerTimothy Gu <timothygu99@gmail.com>2017-02-24 17:49:46 -0800
commitd4e1eaf43cc01ba1d151697f916abff4524062eb (patch)
treebdbdc4cda7ed5c902806e6498b14630e08f6efbf /benchmark
parent2cb5555f253d8d50f6c658033db436bd9e3970d2 (diff)
downloadandroid-node-v8-d4e1eaf43cc01ba1d151697f916abff4524062eb.tar.gz
android-node-v8-d4e1eaf43cc01ba1d151697f916abff4524062eb.tar.bz2
android-node-v8-d4e1eaf43cc01ba1d151697f916abff4524062eb.zip
benchmark: add url.domainTo*()
PR-URL: https://github.com/nodejs/node/pull/11464 Reviewed-By: Steven R Loomis <srloomis@us.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/url/whatwg-url-idna.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/benchmark/url/whatwg-url-idna.js b/benchmark/url/whatwg-url-idna.js
new file mode 100644
index 0000000000..41b4c639de
--- /dev/null
+++ b/benchmark/url/whatwg-url-idna.js
@@ -0,0 +1,47 @@
+'use strict';
+const common = require('../common.js');
+const { domainToASCII, domainToUnicode } = require('url');
+
+const inputs = {
+ empty: {
+ ascii: '',
+ unicode: ''
+ },
+ none: {
+ ascii: 'passports',
+ unicode: 'passports'
+ },
+ some: {
+ ascii: 'Paßstraße',
+ unicode: 'xn--Pastrae-1vae'
+ },
+ all: {
+ ascii: '他们不说中文',
+ unicode: 'xn--ihqwczyycu19kkg2c'
+ },
+ nonstring: {
+ ascii: { toString() { return ''; } },
+ unicode: { toString() { return ''; } }
+ }
+};
+
+const bench = common.createBenchmark(main, {
+ input: Object.keys(inputs),
+ to: ['ascii', 'unicode'],
+ n: [5e6]
+});
+
+function main(conf) {
+ const n = conf.n | 0;
+ const to = conf.to;
+ const input = inputs[conf.input][to];
+ const method = to === 'ascii' ? domainToASCII : domainToUnicode;
+
+ common.v8ForceOptimization(method, input);
+
+ bench.start();
+ for (var i = 0; i < n; i++) {
+ method(input);
+ }
+ bench.end(n);
+}