GeezerVison is showing github.com — benchmark: use let instead of var · ide/node@4bf888d
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: benchmark/module/module-loader-deep.js +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -37,14 +37,13 @@ function main({ ext, cache, files }) { | 37 | 37 | } | 38 | 38 |
| 39 | 39 | function measureDir(cache, files) { | 40 | | - var i; | 41 | 40 | if (cache) { | 42 | | - for (i = 0; i <= files; i++) { | | 41 | + for (let i = 0; i <= files; i++) { | 43 | 42 | require(`${benchmarkDirectory}/${i}`); | 44 | 43 | } | 45 | 44 | } | 46 | 45 | bench.start(); | 47 | | - for (i = 0; i <= files; i++) { | | 46 | + for (let i = 0; i <= files; i++) { | 48 | 47 | require(`${benchmarkDirectory}/${i}`); | 49 | 48 | } | 50 | 49 | bench.end(files); | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/module/module-loader.js +3-4Lines changed: 3 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -42,15 +42,14 @@ function main({ n, name, cache, files, dir }) { | 42 | 42 | } | 43 | 43 |
| 44 | 44 | function measureDir(n, cache, files, name) { | 45 | | - var i; | 46 | 45 | if (cache) { | 47 | | - for (i = 0; i <= files; i++) { | | 46 | + for (let i = 0; i <= files; i++) { | 48 | 47 | require(`${benchmarkDirectory}${i}${name}`); | 49 | 48 | } | 50 | 49 | } | 51 | 50 | bench.start(); | 52 | | - for (i = 0; i <= files; i++) { | 53 | | - for (var j = 0; j < n; j++) | | 51 | + for (let i = 0; i <= files; i++) { | | 52 | + for (let j = 0; j < n; j++) | 54 | 53 | require(`${benchmarkDirectory}${i}${name}`); | 55 | 54 | // Pretend mixed input (otherwise the results are less representative due to | 56 | 55 | // highly specialized code). | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/napi/function_args/index.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -89,7 +89,7 @@ function main({ n, engine, type }) { | 89 | 89 | const args = generateArgs(type); | 90 | 90 |
| 91 | 91 | bench.start(); | 92 | | - for (var i = 0; i < n; i++) { | | 92 | + for (let i = 0; i < n; i++) { | 93 | 93 | fn.apply(null, args); | 94 | 94 | } | 95 | 95 | bench.end(n); | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/napi/function_call/index.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 29 | 29 | } | 30 | 30 | const napi = napi_binding.hello; | 31 | 31 |
| 32 | | -var c = 0; | | 32 | +let c = 0; | 33 | 33 | function js() { | 34 | 34 | return c++; | 35 | 35 | } | @@ -44,7 +44,7 @@ const bench = common.createBenchmark(main, { | 44 | 44 | function main({ n, type }) { | 45 | 45 | const fn = type === 'cxx' ? cxx : type === 'napi' ? napi : js; | 46 | 46 | bench.start(); | 47 | | - for (var i = 0; i < n; i++) { | | 47 | + for (let i = 0; i < n; i++) { | 48 | 48 | fn(); | 49 | 49 | } | 50 | 50 | bench.end(n); | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/net/net-c2s-cork.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,8 +11,8 @@ const bench = common.createBenchmark(main, { | 11 | 11 | dur: [5], | 12 | 12 | }); | 13 | 13 |
| 14 | | -var chunk; | 15 | | -var encoding; | | 14 | +let chunk; | | 15 | +let encoding; | 16 | 16 |
| 17 | 17 | function main({ dur, len, type }) { | 18 | 18 | switch (type) { | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/net/net-c2s.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,8 +11,8 @@ const bench = common.createBenchmark(main, { | 11 | 11 | dur: [5], | 12 | 12 | }); | 13 | 13 |
| 14 | | -var chunk; | 15 | | -var encoding; | | 14 | +let chunk; | | 15 | +let encoding; | 16 | 16 |
| 17 | 17 | function main({ dur, len, type }) { | 18 | 18 | switch (type) { | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/net/net-pipe.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,8 +11,8 @@ const bench = common.createBenchmark(main, { | 11 | 11 | dur: [5], | 12 | 12 | }); | 13 | 13 |
| 14 | | -var chunk; | 15 | | -var encoding; | | 14 | +let chunk; | | 15 | +let encoding; | 16 | 16 |
| 17 | 17 | function main({ dur, len, type }) { | 18 | 18 | switch (type) { | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/net/net-s2c.js +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,10 +12,10 @@ const bench = common.createBenchmark(main, { | 12 | 12 | dur: [5] | 13 | 13 | }); | 14 | 14 |
| 15 | | -var chunk; | 16 | | -var encoding; | 17 | | -var recvbuf; | 18 | | -var received = 0; | | 15 | +let chunk; | | 16 | +let encoding; | | 17 | +let recvbuf; | | 18 | +let received = 0; | 19 | 19 |
| 20 | 20 | function main({ dur, sendchunklen, type, recvbuflen, recvbufgenfn }) { | 21 | 21 | if (isFinite(recvbuflen) && recvbuflen > 0) | @@ -38,8 +38,8 @@ function main({ dur, sendchunklen, type, recvbuflen, recvbufgenfn }) { | 38 | 38 | } | 39 | 39 |
| 40 | 40 | const reader = new Reader(); | 41 | | - var writer; | 42 | | - var socketOpts; | | 41 | + let writer; | | 42 | + let socketOpts; | 43 | 43 | if (recvbuf === undefined) { | 44 | 44 | writer = new Writer(); | 45 | 45 | socketOpts = { port: PORT }; | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/net/net-wrap-js-stream-passthrough.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,8 +12,8 @@ const bench = common.createBenchmark(main, { | 12 | 12 | flags: ['--expose-internals'] | 13 | 13 | }); | 14 | 14 |
| 15 | | -var chunk; | 16 | | -var encoding; | | 15 | +let chunk; | | 16 | +let encoding; | 17 | 17 |
| 18 | 18 | function main({ dur, len, type }) { | 19 | 19 | // Can only require internals inside main(). | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/net/tcp-raw-c2s.js +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -24,7 +24,7 @@ function main({ dur, len, type }) { | 24 | 24 | const PORT = common.PORT; | 25 | 25 |
| 26 | 26 | const serverHandle = new TCP(TCPConstants.SERVER); | 27 | | - var err = serverHandle.bind('127.0.0.1', PORT); | | 27 | + let err = serverHandle.bind('127.0.0.1', PORT); | 28 | 28 | if (err) | 29 | 29 | fail(err, 'bind'); | 30 | 30 |
| @@ -38,7 +38,7 @@ function main({ dur, len, type }) { | 38 | 38 |
| 39 | 39 | // The meat of the benchmark is right here: | 40 | 40 | bench.start(); | 41 | | - var bytes = 0; | | 41 | + let bytes = 0; | 42 | 42 |
| 43 | 43 | setTimeout(() => { | 44 | 44 | // report in Gb/sec | @@ -67,7 +67,7 @@ function main({ dur, len, type }) { | 67 | 67 | } | 68 | 68 |
| 69 | 69 | function client(type, len) { | 70 | | - var chunk; | | 70 | + let chunk; | 71 | 71 | switch (type) { | 72 | 72 | case 'buf': | 73 | 73 | chunk = Buffer.alloc(len, 'x'); | @@ -102,7 +102,7 @@ function main({ dur, len, type }) { | 102 | 102 | function write() { | 103 | 103 | const writeReq = new WriteWrap(); | 104 | 104 | writeReq.oncomplete = afterWrite; | 105 | | - var err; | | 105 | + let err; | 106 | 106 | switch (type) { | 107 | 107 | case 'buf': | 108 | 108 | err = clientHandle.writeBuffer(writeReq, chunk); | |
|