| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 916b319 commit a021f19
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,37 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common.js'); | ||
| 3 | + const bench = common.createBenchmark(main, { | ||
| 4 | + n: [1e4, 2e4, 4e4], | ||
| 5 | + loop: [1e2, 2e2], | ||
| 6 | + }); | ||
| 7 | + | ||
| 8 | + function main({ n, loop }) { | ||
| 9 | + bench.start(); | ||
| 10 | + run(); | ||
| 11 | + function run() { | ||
| 12 | + let j = 0; | ||
| 13 | + | ||
| 14 | + function cb() { | ||
| 15 | + j++; | ||
| 16 | + if (j === n) { | ||
| 17 | + loop--; | ||
| 18 | + if (loop === 0) { | ||
| 19 | + bench.end(n); | ||
| 20 | + } else { | ||
| 21 | + run(); | ||
| 22 | + } | ||
| 23 | + } | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + for (let i = 0; i < n; i++) { | ||
| 27 | + if (i % 4 === 0) | ||
| 28 | + process.nextTick(cb, i, true, 10, 'test'); | ||
| 29 | + else if (i % 3 === 0) | ||
| 30 | + process.nextTick(cb, i, true, 10); | ||
| 31 | + else if (i % 2 === 0) | ||
| 32 | + process.nextTick(cb, i, 20); | ||
| 33 | + else | ||
| 34 | + process.nextTick(cb, i); | ||
| 35 | + } | ||
| 36 | + } | ||
| 37 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,30 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common.js'); | ||
| 3 | + const bench = common.createBenchmark(main, { | ||
| 4 | + n: [1e4, 2e4, 4e4], | ||
| 5 | + loop: [1e2, 2e2], | ||
| 6 | + }); | ||
| 7 | + | ||
| 8 | + function main({ n, loop }) { | ||
| 9 | + bench.start(); | ||
| 10 | + run(); | ||
| 11 | + function run() { | ||
| 12 | + let j = 0; | ||
| 13 | + | ||
| 14 | + function cb() { | ||
| 15 | + j++; | ||
| 16 | + if (j === n) { | ||
| 17 | + loop--; | ||
| 18 | + if (loop === 0) { | ||
| 19 | + bench.end(n); | ||
| 20 | + } else { | ||
| 21 | + run(); | ||
| 22 | + } | ||
| 23 | + } | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + for (let i = 0; i < n; i++) { | ||
| 27 | + process.nextTick(cb); | ||
| 28 | + } | ||
| 29 | + } | ||
| 30 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -111,6 +111,7 @@ module.exports = class FixedQueue { | |||
| 111 | 111 | if (tail.isEmpty() && tail.next !== null) { | |
| 112 | 112 | // If there is another queue, it forms the new tail. | |
| 113 | 113 | this.tail = tail.next; | |
| 114 | + tail.next = null; | ||
| 114 | 115 | } | |
| 115 | 116 | return next; | |
| 116 | 117 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments