GeezerVison is showing github.com — benchmark: var to const · ide/node@e167ab7
File treeExpand file treeCollapse file tree Open diff view settings Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: benchmark/_benchmark_progress.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | const readline = require('readline'); | 4 | 4 |
| 5 | 5 | function pad(input, minLength, fill) { | 6 | | - var result = String(input); | 7 | | - var padding = fill.repeat(Math.max(0, minLength - result.length)); | | 6 | + const result = String(input); | | 7 | + const padding = fill.repeat(Math.max(0, minLength - result.length)); | 8 | 8 | return `${padding}${result}`; | 9 | 9 | } | 10 | 10 |
| |
Collapse file Copy file name to clipboardExpand all lines: benchmark/arrays/var-int.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -23,7 +23,7 @@ function main(conf) { | 23 | 23 | const n = +conf.n; | 24 | 24 |
| 25 | 25 | bench.start(); | 26 | | - var arr = new clazz(n * 1e6); | | 26 | + const arr = new clazz(n * 1e6); | 27 | 27 | for (var i = 0; i < 10; ++i) { | 28 | 28 | run(); | 29 | 29 | } | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/arrays/zero-float.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -23,7 +23,7 @@ function main(conf) { | 23 | 23 | const n = +conf.n; | 24 | 24 |
| 25 | 25 | bench.start(); | 26 | | - var arr = new clazz(n * 1e6); | | 26 | + const arr = new clazz(n * 1e6); | 27 | 27 | for (var i = 0; i < 10; ++i) { | 28 | 28 | run(); | 29 | 29 | } | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/arrays/zero-int.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -23,7 +23,7 @@ function main(conf) { | 23 | 23 | const n = +conf.n; | 24 | 24 |
| 25 | 25 | bench.start(); | 26 | | - var arr = new clazz(n * 1e6); | | 26 | + const arr = new clazz(n * 1e6); | 27 | 27 | for (var i = 0; i < 10; ++i) { | 28 | 28 | run(); | 29 | 29 | } | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-base64-encode.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 20 | 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | 21 |
| 22 | 22 | 'use strict'; | 23 | | -var common = require('../common.js'); | | 23 | +const common = require('../common.js'); | 24 | 24 |
| 25 | 25 | const bench = common.createBenchmark(main, { | 26 | 26 | len: [64 * 1024 * 1024], | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-bytelength.js +10-10Lines changed: 10 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | | -var common = require('../common'); | | 2 | +const common = require('../common'); | 3 | 3 |
| 4 | | -var bench = common.createBenchmark(main, { | | 4 | +const bench = common.createBenchmark(main, { | 5 | 5 | encoding: ['utf8', 'base64', 'buffer'], | 6 | 6 | len: [1, 2, 4, 16, 64, 256], // x16 | 7 | 7 | n: [5e6] | 8 | 8 | }); | 9 | 9 |
| 10 | 10 | // 16 chars each | 11 | | -var chars = [ | | 11 | +const chars = [ | 12 | 12 | 'hello brendan!!!', // 1 byte | 13 | 13 | 'ΰαβγδεζηθικλμνξο', // 2 bytes | 14 | 14 | '挰挱挲挳挴挵挶挷挸挹挺挻挼挽挾挿', // 3 bytes | 15 | 15 | '𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢' // 4 bytes | 16 | 16 | ]; | 17 | 17 |
| 18 | 18 | function main(conf) { | 19 | | - var n = conf.n | 0; | 20 | | - var len = conf.len | 0; | 21 | | - var encoding = conf.encoding; | | 19 | + const n = conf.n | 0; | | 20 | + const len = conf.len | 0; | | 21 | + const encoding = conf.encoding; | 22 | 22 |
| 23 | 23 | var strings = []; | 24 | 24 | var results; | 25 | 25 | if (encoding === 'buffer') { | 26 | 26 | strings = [ Buffer.alloc(len * 16, 'a') ]; | 27 | 27 | results = [ len * 16 ]; | 28 | 28 | } else { | 29 | | - for (var string of chars) { | | 29 | + for (const string of chars) { | 30 | 30 | // Strings must be built differently, depending on encoding | 31 | | - var data = string.repeat(len); | | 31 | + const data = string.repeat(len); | 32 | 32 | if (encoding === 'utf8') { | 33 | 33 | strings.push(data); | 34 | 34 | } else if (encoding === 'base64') { | @@ -45,9 +45,9 @@ function main(conf) { | 45 | 45 |
| 46 | 46 | bench.start(); | 47 | 47 | for (var i = 0; i < n; i++) { | 48 | | - var index = n % strings.length; | | 48 | + const index = n % strings.length; | 49 | 49 | // Go! | 50 | | - var r = Buffer.byteLength(strings[index], encoding); | | 50 | + const r = Buffer.byteLength(strings[index], encoding); | 51 | 51 |
| 52 | 52 | if (r !== results[index]) | 53 | 53 | throw new Error('incorrect return value'); | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-compare.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 20 | 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | 21 |
| 22 | 22 | 'use strict'; | 23 | | -var common = require('../common.js'); | | 23 | +const common = require('../common.js'); | 24 | 24 |
| 25 | | -var bench = common.createBenchmark(main, { | | 25 | +const bench = common.createBenchmark(main, { | 26 | 26 | size: [16, 512, 1024, 4096, 16386], | 27 | 27 | millions: [1] | 28 | 28 | }); | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-indexof.js +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | | -var common = require('../common.js'); | 3 | | -var fs = require('fs'); | | 2 | +const common = require('../common.js'); | | 3 | +const fs = require('fs'); | 4 | 4 | const path = require('path'); | 5 | 5 |
| 6 | 6 | const searchStrings = [ | @@ -21,15 +21,15 @@ const searchStrings = [ | 21 | 21 | '</i> to the Caterpillar' | 22 | 22 | ]; | 23 | 23 |
| 24 | | -var bench = common.createBenchmark(main, { | | 24 | +const bench = common.createBenchmark(main, { | 25 | 25 | search: searchStrings, | 26 | 26 | encoding: ['undefined', 'utf8', 'ucs2', 'binary'], | 27 | 27 | type: ['buffer', 'string'], | 28 | 28 | iter: [1] | 29 | 29 | }); | 30 | 30 |
| 31 | 31 | function main(conf) { | 32 | | - var iter = (conf.iter) * 100000; | | 32 | + const iter = (conf.iter) * 100000; | 33 | 33 | var aliceBuffer = fs.readFileSync( | 34 | 34 | path.resolve(__dirname, '../fixtures/alice.html') | 35 | 35 | ); | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-iterate.js +7-7Lines changed: 7 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | | -var SlowBuffer = require('buffer').SlowBuffer; | 3 | | -var common = require('../common.js'); | 4 | | -var assert = require('assert'); | | 2 | +const SlowBuffer = require('buffer').SlowBuffer; | | 3 | +const common = require('../common.js'); | | 4 | +const assert = require('assert'); | 5 | 5 |
| 6 | | -var bench = common.createBenchmark(main, { | | 6 | +const bench = common.createBenchmark(main, { | 7 | 7 | size: [16, 512, 1024, 4096, 16386], | 8 | 8 | type: ['fast', 'slow'], | 9 | 9 | method: ['for', 'forOf', 'iterator'], | 10 | 10 | n: [1e3] | 11 | 11 | }); | 12 | 12 |
| 13 | | -var methods = { | | 13 | +const methods = { | 14 | 14 | 'for': benchFor, | 15 | 15 | 'forOf': benchForOf, | 16 | 16 | 'iterator': benchIterator | @@ -43,7 +43,7 @@ function benchForOf(buffer, n) { | 43 | 43 | bench.start(); | 44 | 44 |
| 45 | 45 | for (var k = 0; k < n; k++) { | 46 | | - for (var b of buffer) { | | 46 | + for (const b of buffer) { | 47 | 47 | assert(b === 0); | 48 | 48 | } | 49 | 49 | } | @@ -54,7 +54,7 @@ function benchIterator(buffer, n) { | 54 | 54 | bench.start(); | 55 | 55 |
| 56 | 56 | for (var k = 0; k < n; k++) { | 57 | | - var iter = buffer[Symbol.iterator](); | | 57 | + const iter = buffer[Symbol.iterator](); | 58 | 58 | var cur = iter.next(); | 59 | 59 |
| 60 | 60 | while (!cur.done) { | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-read.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | | -var common = require('../common.js'); | | 2 | +const common = require('../common.js'); | 3 | 3 |
| 4 | | -var types = [ | | 4 | +const types = [ | 5 | 5 | 'UInt8', | 6 | 6 | 'UInt16LE', | 7 | 7 | 'UInt16BE', | @@ -18,7 +18,7 @@ var types = [ | 18 | 18 | 'DoubleBE' | 19 | 19 | ]; | 20 | 20 |
| 21 | | -var bench = common.createBenchmark(main, { | | 21 | +const bench = common.createBenchmark(main, { | 22 | 22 | noAssert: ['false', 'true'], | 23 | 23 | buffer: ['fast', 'slow'], | 24 | 24 | type: types, | |
|