| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,22 +22,23 @@ function endAfterGC(n) { | |||
| 22 | 22 | } | |
| 23 | 23 | ||
| 24 | 24 | function main({ n, method }) { | |
| 25 | + var i; | ||
| 25 | 26 | switch (method) { | |
| 26 | 27 | case 'trackingEnabled': | |
| 27 | 28 | bench.start(); | |
| 28 | - for (let i = 0; i < n; i++) { | ||
| 29 | + for (i = 0; i < n; i++) { | ||
| 29 | 30 | new AsyncResource('foobar'); | |
| 30 | 31 | } | |
| 31 | 32 | endAfterGC(n); | |
| 32 | 33 | break; | |
| 33 | 34 | case 'trackingDisabled': | |
| 34 | 35 | bench.start(); | |
| 35 | - for (let i = 0; i < n; i++) { | ||
| 36 | + for (i = 0; i < n; i++) { | ||
| 36 | 37 | new AsyncResource('foobar', { requireManualDestroy: true }); | |
| 37 | 38 | } | |
| 38 | 39 | endAfterGC(n); | |
| 39 | 40 | break; | |
| 40 | 41 | default: | |
| 41 | - throw new Error('Unsupported method'); | ||
| 42 | + throw new Error(`Unsupported method "${method}"`); | ||
| 42 | 43 | } | |
| 43 | 44 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,18 +15,19 @@ const noop = () => {}; | |||
| 15 | 15 | function main({ n, port, address }) { | |
| 16 | 16 | port = port === 'true' ? 0 : undefined; | |
| 17 | 17 | address = address === 'true' ? '0.0.0.0' : undefined; | |
| 18 | + var i; | ||
| 18 | 19 | ||
| 19 | 20 | if (port !== undefined && address !== undefined) { | |
| 20 | 21 | bench.start(); | |
| 21 | - for (let i = 0; i < n; i++) { | ||
| 22 | + for (i = 0; i < n; i++) { | ||
| 22 | 23 | dgram.createSocket('udp4').bind(port, address) | |
| 23 | 24 | .on('error', noop) | |
| 24 | 25 | .unref(); | |
| 25 | 26 | } | |
| 26 | 27 | bench.end(n); | |
| 27 | 28 | } else if (port !== undefined) { | |
| 28 | 29 | bench.start(); | |
| 29 | - for (let i = 0; i < n; i++) { | ||
| 30 | + for (i = 0; i < n; i++) { | ||
| 30 | 31 | dgram.createSocket('udp4') | |
| 31 | 32 | .bind(port) | |
| 32 | 33 | .on('error', noop) | |
@@ -35,7 +36,7 @@ function main({ n, port, address }) { | |||
| 35 | 36 | bench.end(n); | |
| 36 | 37 | } else if (port === undefined && address === undefined) { | |
| 37 | 38 | bench.start(); | |
| 38 | - for (let i = 0; i < n; i++) { | ||
| 39 | + for (i = 0; i < n; i++) { | ||
| 39 | 40 | dgram.createSocket('udp4') | |
| 40 | 41 | .bind() | |
| 41 | 42 | .on('error', noop) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,15 +28,6 @@ function main({ n, args }) { | |||
| 28 | 28 | bench.end(n); | |
| 29 | 29 | } | |
| 30 | 30 | ||
| 31 | - function fn(a, b, c) { | ||
| 32 | - if (!a) | ||
| 33 | - a = 1; | ||
| 34 | - | ||
| 35 | - if (!b) | ||
| 36 | - b = 2; | ||
| 37 | - | ||
| 38 | - if (!c) | ||
| 39 | - c = 3; | ||
| 40 | - | ||
| 31 | + function fn(a = 1, b = 2, c = 3) { | ||
| 41 | 32 | return a + b + c; | |
| 42 | 33 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,10 +16,8 @@ function main({ n, pathType }) { | |||
| 16 | 16 | bench.start(); | |
| 17 | 17 | if (pathType === 'relative') | |
| 18 | 18 | relativePath(n); | |
| 19 | - else if (pathType === 'resolved') | ||
| 20 | - resolvedPath(n); | ||
| 21 | 19 | else | |
| 22 | - throw new Error(`unknown "pathType": ${pathType}`); | ||
| 20 | + resolvedPath(n); | ||
| 23 | 21 | } | |
| 24 | 22 | ||
| 25 | 23 | function relativePath(n) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,24 +15,10 @@ const bench = common.createBenchmark(main, { | |||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | 17 | function main({ n, pathType }) { | |
| 18 | + const path = pathType === 'relative' ? relative_path : resolved_path; | ||
| 18 | 19 | bench.start(); | |
| 19 | - if (pathType === 'relative') | ||
| 20 | - relativePath(n); | ||
| 21 | - else if (pathType === 'resolved') | ||
| 22 | - resolvedPath(n); | ||
| 23 | - else | ||
| 24 | - throw new Error(`unknown "pathType": ${pathType}`); | ||
| 25 | - bench.end(n); | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | - function relativePath(n) { | ||
| 29 | - for (var i = 0; i < n; i++) { | ||
| 30 | - fs.realpathSync(relative_path); | ||
| 31 | - } | ||
| 32 | - } | ||
| 33 | - | ||
| 34 | - function resolvedPath(n) { | ||
| 35 | 20 | for (var i = 0; i < n; i++) { | |
| 36 | - fs.realpathSync(resolved_path); | ||
| 21 | + fs.realpathSync(path); | ||
| 37 | 22 | } | |
| 23 | + bench.end(n); | ||
| 38 | 24 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,6 @@ function main({ dur, encodingType, size }) { | |||
| 36 | 36 | try { fs.unlinkSync(filename); } catch (e) {} | |
| 37 | 37 | ||
| 38 | 38 | var started = false; | |
| 39 | - var ending = false; | ||
| 40 | 39 | var ended = false; | |
| 41 | 40 | ||
| 42 | 41 | var f = fs.createWriteStream(filename); | |
@@ -52,15 +51,9 @@ function main({ dur, encodingType, size }) { | |||
| 52 | 51 | ||
| 53 | 52 | ||
| 54 | 53 | function write() { | |
| 55 | - // don't try to write after we end, even if a 'drain' event comes. | ||
| 56 | - // v0.8 streams are so sloppy! | ||
| 57 | - if (ending) | ||
| 58 | - return; | ||
| 59 | - | ||
| 60 | 54 | if (!started) { | |
| 61 | 55 | started = true; | |
| 62 | 56 | setTimeout(function() { | |
| 63 | - ending = true; | ||
| 64 | 57 | f.end(); | |
| 65 | 58 | }, dur * 1000); | |
| 66 | 59 | bench.start(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,6 @@ function main({ n }) { | |||
| 12 | 12 | const FreeList = require('internal/freelist'); | |
| 13 | 13 | const poolSize = 1000; | |
| 14 | 14 | const list = new FreeList('test', poolSize, Object); | |
| 15 | - var i; | ||
| 16 | 15 | var j; | |
| 17 | 16 | const used = []; | |
| 18 | 17 | ||
@@ -23,7 +22,7 @@ function main({ n }) { | |||
| 23 | 22 | ||
| 24 | 23 | bench.start(); | |
| 25 | 24 | ||
| 26 | - for (i = 0; i < n; i++) { | ||
| 25 | + for (var i = 0; i < n; i++) { | ||
| 27 | 26 | // Return all the items to the pool | |
| 28 | 27 | for (j = 0; j < poolSize; j++) { | |
| 29 | 28 | list.free(used[j]); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,11 +32,9 @@ const bench = common.createBenchmark(main, { | |||
| 32 | 32 | }); | |
| 33 | 33 | ||
| 34 | 34 | function main({ millions, type }) { | |
| 35 | - const n = millions * 1e6; | ||
| 36 | - | ||
| 37 | 35 | const fn = type === 'cxx' ? cxx : js; | |
| 38 | 36 | bench.start(); | |
| 39 | - for (var i = 0; i < n; i++) { | ||
| 37 | + for (var i = 0; i < millions * 1e6; i++) { | ||
| 40 | 38 | fn(); | |
| 41 | 39 | } | |
| 42 | 40 | bench.end(millions); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,6 +78,6 @@ function main({ millions, method }) { | |||
| 78 | 78 | runSymbol(n); | |
| 79 | 79 | break; | |
| 80 | 80 | default: | |
| 81 | - throw new Error('Unexpected method'); | ||
| 81 | + throw new Error(`Unexpected method "${method}"`); | ||
| 82 | 82 | } | |
| 83 | 83 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,9 +55,8 @@ function runPunycode(n, val) { | |||
| 55 | 55 | } | |
| 56 | 56 | ||
| 57 | 57 | function runICU(n, val) { | |
| 58 | - var i = 0; | ||
| 59 | 58 | bench.start(); | |
| 60 | - for (; i < n; i++) | ||
| 59 | + for (var i = 0; i < n; i++) | ||
| 61 | 60 | usingICU(val); | |
| 62 | 61 | bench.end(n); | |
| 63 | 62 | } | |
@@ -76,6 +75,6 @@ function main({ n, val, method }) { | |||
| 76 | 75 | } | |
| 77 | 76 | // fallthrough | |
| 78 | 77 | default: | |
| 79 | - throw new Error('Unexpected method'); | ||
| 78 | + throw new Error(`Unexpected method "${method}"`); | ||
| 80 | 79 | } | |
| 81 | 80 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments