diff options
author | Vse Mozhet Byt <vsemozhetbyt@gmail.com> | 2017-04-03 00:32:50 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-04-04 09:19:18 -0700 |
commit | 74dc3bfe08b8f0a47759206d3d9d4d6f5a0528c1 (patch) | |
tree | 11c56785a6c9b4331314eee66f1dca0fff8b3176 /benchmark/net | |
parent | 9348f31c2aec996cf6cf7731244b2d76153440ea (diff) | |
download | android-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/net')
-rw-r--r-- | benchmark/net/net-c2s-cork.js | 4 | ||||
-rw-r--r-- | benchmark/net/net-c2s.js | 4 | ||||
-rw-r--r-- | benchmark/net/net-pipe.js | 4 | ||||
-rw-r--r-- | benchmark/net/net-s2c.js | 4 | ||||
-rw-r--r-- | benchmark/net/tcp-raw-c2s.js | 4 | ||||
-rw-r--r-- | benchmark/net/tcp-raw-pipe.js | 4 | ||||
-rw-r--r-- | benchmark/net/tcp-raw-s2c.js | 4 |
7 files changed, 14 insertions, 14 deletions
diff --git a/benchmark/net/net-c2s-cork.js b/benchmark/net/net-c2s-cork.js index 6af9162025..4a119e9c27 100644 --- a/benchmark/net/net-c2s-cork.js +++ b/benchmark/net/net-c2s-cork.js @@ -27,11 +27,11 @@ function main(conf) { break; case 'utf': encoding = 'utf8'; - chunk = new Array(len / 2 + 1).join('ü'); + chunk = 'ü'.repeat(len / 2); break; case 'asc': encoding = 'ascii'; - chunk = new Array(len + 1).join('x'); + chunk = 'x'.repeat(len); break; default: throw new Error('invalid type: ' + type); diff --git a/benchmark/net/net-c2s.js b/benchmark/net/net-c2s.js index 7e59bc528b..fdc5cfc5c7 100644 --- a/benchmark/net/net-c2s.js +++ b/benchmark/net/net-c2s.js @@ -27,11 +27,11 @@ function main(conf) { break; case 'utf': encoding = 'utf8'; - chunk = new Array(len / 2 + 1).join('ü'); + chunk = 'ü'.repeat(len / 2); break; case 'asc': encoding = 'ascii'; - chunk = new Array(len + 1).join('x'); + chunk = 'x'.repeat(len); break; default: throw new Error('invalid type: ' + type); diff --git a/benchmark/net/net-pipe.js b/benchmark/net/net-pipe.js index 7d4849c4ef..d40da7e549 100644 --- a/benchmark/net/net-pipe.js +++ b/benchmark/net/net-pipe.js @@ -27,11 +27,11 @@ function main(conf) { break; case 'utf': encoding = 'utf8'; - chunk = new Array(len / 2 + 1).join('ü'); + chunk = 'ü'.repeat(len / 2); break; case 'asc': encoding = 'ascii'; - chunk = new Array(len + 1).join('x'); + chunk = 'x'.repeat(len); break; default: throw new Error('invalid type: ' + type); diff --git a/benchmark/net/net-s2c.js b/benchmark/net/net-s2c.js index a4a5b4ab49..1c104e3417 100644 --- a/benchmark/net/net-s2c.js +++ b/benchmark/net/net-s2c.js @@ -27,11 +27,11 @@ function main(conf) { break; case 'utf': encoding = 'utf8'; - chunk = new Array(len / 2 + 1).join('ü'); + chunk = 'ü'.repeat(len / 2); break; case 'asc': encoding = 'ascii'; - chunk = new Array(len + 1).join('x'); + chunk = 'x'.repeat(len); break; default: throw new Error('invalid type: ' + type); diff --git a/benchmark/net/tcp-raw-c2s.js b/benchmark/net/tcp-raw-c2s.js index c33c6d0f2a..8c9eff76e9 100644 --- a/benchmark/net/tcp-raw-c2s.js +++ b/benchmark/net/tcp-raw-c2s.js @@ -83,10 +83,10 @@ function client() { chunk = Buffer.alloc(len, 'x'); break; case 'utf': - chunk = new Array(len / 2 + 1).join('ü'); + chunk = 'ü'.repeat(len / 2); break; case 'asc': - chunk = new Array(len + 1).join('x'); + chunk = 'x'.repeat(len); break; default: throw new Error('invalid type: ' + type); diff --git a/benchmark/net/tcp-raw-pipe.js b/benchmark/net/tcp-raw-pipe.js index b7c6776c95..0501d13f00 100644 --- a/benchmark/net/tcp-raw-pipe.js +++ b/benchmark/net/tcp-raw-pipe.js @@ -80,10 +80,10 @@ function client() { chunk = Buffer.alloc(len, 'x'); break; case 'utf': - chunk = new Array(len / 2 + 1).join('ü'); + chunk = 'ü'.repeat(len / 2); break; case 'asc': - chunk = new Array(len + 1).join('x'); + chunk = 'x'.repeat(len); break; default: throw new Error('invalid type: ' + type); diff --git a/benchmark/net/tcp-raw-s2c.js b/benchmark/net/tcp-raw-s2c.js index a7eeed1921..1cb0fb63f4 100644 --- a/benchmark/net/tcp-raw-s2c.js +++ b/benchmark/net/tcp-raw-s2c.js @@ -54,10 +54,10 @@ function server() { chunk = Buffer.alloc(len, 'x'); break; case 'utf': - chunk = new Array(len / 2 + 1).join('ü'); + chunk = 'ü'.repeat(len / 2); break; case 'asc': - chunk = new Array(len + 1).join('x'); + chunk = 'x'.repeat(len); break; default: throw new Error('invalid type: ' + type); |