summaryrefslogtreecommitdiff
path: root/benchmark/crypto
diff options
context:
space:
mode:
authorVse Mozhet Byt <vsemozhetbyt@gmail.com>2017-04-03 00:32:50 +0300
committerJames M Snell <jasnell@gmail.com>2017-04-04 09:19:18 -0700
commit74dc3bfe08b8f0a47759206d3d9d4d6f5a0528c1 (patch)
tree11c56785a6c9b4331314eee66f1dca0fff8b3176 /benchmark/crypto
parent9348f31c2aec996cf6cf7731244b2d76153440ea (diff)
downloadandroid-node-v8-74dc3bfe08b8f0a47759206d3d9d4d6f5a0528c1.tar.gz
android-node-v8-74dc3bfe08b8f0a47759206d3d9d4d6f5a0528c1.tar.bz2
android-node-v8-74dc3bfe08b8f0a47759206d3d9d4d6f5a0528c1.zip
benchmark: replace [].join() with ''.repeat()
Also add a benchmark to compare both ways to create strings. PR-URL: https://github.com/nodejs/node/pull/12170 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'benchmark/crypto')
-rw-r--r--benchmark/crypto/cipher-stream.js4
-rw-r--r--benchmark/crypto/hash-stream-creation.js4
-rw-r--r--benchmark/crypto/hash-stream-throughput.js4
3 files changed, 6 insertions, 6 deletions
diff --git a/benchmark/crypto/cipher-stream.js b/benchmark/crypto/cipher-stream.js
index 11e2c38c0b..03780ba130 100644
--- a/benchmark/crypto/cipher-stream.js
+++ b/benchmark/crypto/cipher-stream.js
@@ -40,11 +40,11 @@ function main(conf) {
var encoding;
switch (conf.type) {
case 'asc':
- message = new Array(conf.len + 1).join('a');
+ message = 'a'.repeat(conf.len);
encoding = 'ascii';
break;
case 'utf':
- message = new Array(conf.len / 2 + 1).join('ü');
+ message = 'ü'.repeat(conf.len / 2);
encoding = 'utf8';
break;
case 'buf':
diff --git a/benchmark/crypto/hash-stream-creation.js b/benchmark/crypto/hash-stream-creation.js
index e7fcde3aa6..3be09785ac 100644
--- a/benchmark/crypto/hash-stream-creation.js
+++ b/benchmark/crypto/hash-stream-creation.js
@@ -25,11 +25,11 @@ function main(conf) {
var encoding;
switch (conf.type) {
case 'asc':
- message = new Array(conf.len + 1).join('a');
+ message = 'a'.repeat(conf.len);
encoding = 'ascii';
break;
case 'utf':
- message = new Array(conf.len / 2 + 1).join('ü');
+ message = 'ü'.repeat(conf.len / 2);
encoding = 'utf8';
break;
case 'buf':
diff --git a/benchmark/crypto/hash-stream-throughput.js b/benchmark/crypto/hash-stream-throughput.js
index 732c2b89c7..bf426fc2c9 100644
--- a/benchmark/crypto/hash-stream-throughput.js
+++ b/benchmark/crypto/hash-stream-throughput.js
@@ -24,11 +24,11 @@ function main(conf) {
var encoding;
switch (conf.type) {
case 'asc':
- message = new Array(conf.len + 1).join('a');
+ message = 'a'.repeat(conf.len);
encoding = 'ascii';
break;
case 'utf':
- message = new Array(conf.len / 2 + 1).join('ü');
+ message = 'ü'.repeat(conf.len / 2);
encoding = 'utf8';
break;
case 'buf':