GeezerVison is showing github.com — test: remove common.busyLoop() · nodejs/node@1fa7347
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: test/common/README.md -5Lines changed: 0 additions & 5 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -45,11 +45,6 @@ tasks. | 45 | 45 |
| 46 | 46 | Takes `whitelist` and concats that with predefined `knownGlobals`. | 47 | 47 |
| 48 | | -### busyLoop(time) | 49 | | -* `time` [<number>][] | 50 | | - | 51 | | -Blocks for `time` amount of time. | 52 | | - | 53 | 48 | ### canCreateSymLink() | 54 | 49 | * return [<boolean>][] | 55 | 50 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/common/index.js -7Lines changed: 0 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -464,12 +464,6 @@ function nodeProcessAborted(exitCode, signal) { | 464 | 464 | } | 465 | 465 | } | 466 | 466 |
| 467 | | -function busyLoop(time) { | 468 | | - const startTime = Date.now(); | 469 | | - const stopTime = startTime + time; | 470 | | - while (Date.now() < stopTime) {} | 471 | | -} | 472 | | - | 473 | 467 | function isAlive(pid) { | 474 | 468 | try { | 475 | 469 | process.kill(pid, 'SIGCONT'); | @@ -727,7 +721,6 @@ function runWithInvalidFD(func) { | 727 | 721 | module.exports = { | 728 | 722 | allowGlobals, | 729 | 723 | buildType, | 730 | | - busyLoop, | 731 | 724 | canCreateSymLink, | 732 | 725 | childShouldThrowAndAbort, | 733 | 726 | createZeroFilledFile, | |
Collapse file Copy file name to clipboardExpand all lines: test/common/index.mjs -2Lines changed: 0 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -40,7 +40,6 @@ const { | 40 | 40 | skip, | 41 | 41 | ArrayStream, | 42 | 42 | nodeProcessAborted, | 43 | | - busyLoop, | 44 | 43 | isAlive, | 45 | 44 | expectWarning, | 46 | 45 | expectsError, | @@ -87,7 +86,6 @@ export { | 87 | 86 | skip, | 88 | 87 | ArrayStream, | 89 | 88 | nodeProcessAborted, | 90 | | - busyLoop, | 91 | 89 | isAlive, | 92 | 90 | expectWarning, | 93 | 91 | expectsError, | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-timers-nested.js +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// Flags: --expose-internals | 1 | 2 | 'use strict'; | 2 | 3 |
| 3 | | -const common = require('../common'); | | 4 | +require('../common'); | 4 | 5 | const assert = require('assert'); | | 6 | +const { sleep } = require('internal/util'); | 5 | 7 |
| 6 | 8 | // Make sure we test 0ms timers, since they would had always wanted to run on | 7 | 9 | // the current tick, and greater than 0ms timers, for scenarios where the | @@ -23,7 +25,7 @@ scenarios.forEach(function(delay) { | 23 | 25 |
| 24 | 26 | // Busy loop for the same timeout used for the nested timer to ensure that | 25 | 27 | // we are in fact expiring the nested timer. | 26 | | - common.busyLoop(delay); | | 28 | + sleep(delay); | 27 | 29 |
| 28 | 30 | // The purpose of running this assert in nextTick is to make sure it runs | 29 | 31 | // after A but before the next iteration of the libuv event loop. | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-timers-next-tick.js +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// Flags: --expose-internals | 1 | 2 | 'use strict'; | 2 | 3 |
| 3 | 4 | const common = require('../common'); | | 5 | +const { sleep } = require('internal/util'); | 4 | 6 |
| 5 | 7 | // This test verifies that the next tick queue runs after each | 6 | 8 | // individual Timeout, as well as each individual Immediate. | @@ -16,7 +18,7 @@ const t2 = setTimeout(common.mustNotCall(), 1); | 16 | 18 | const t3 = setTimeout(common.mustNotCall(), 1); | 17 | 19 | setTimeout(common.mustCall(), 1); | 18 | 20 |
| 19 | | -common.busyLoop(5); | | 21 | +sleep(5); | 20 | 22 |
| 21 | 23 | setImmediate(common.mustCall(() => { | 22 | 24 | process.nextTick(() => { | |
Collapse file Copy file name to clipboardExpand all lines: test/sequential/test-performance-eventloopdelay.js +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -// Flags: --expose-gc | | 1 | +// Flags: --expose-gc --expose-internals | 2 | 2 | 'use strict'; | 3 | 3 |
| 4 | 4 | const common = require('../common'); | 5 | 5 | const assert = require('assert'); | 6 | 6 | const { | 7 | 7 | monitorEventLoopDelay | 8 | 8 | } = require('perf_hooks'); | | 9 | +const { sleep } = require('internal/util'); | 9 | 10 |
| 10 | 11 | { | 11 | 12 | const histogram = monitorEventLoopDelay(); | @@ -54,7 +55,7 @@ const { | 54 | 55 | histogram.enable(); | 55 | 56 | let m = 5; | 56 | 57 | function spinAWhile() { | 57 | | - common.busyLoop(1000); | | 58 | + sleep(1000); | 58 | 59 | if (--m > 0) { | 59 | 60 | setTimeout(spinAWhile, common.platformTimeout(500)); | 60 | 61 | } else { | |
Collapse file Copy file name to clipboardExpand all lines: test/sequential/test-timers-block-eventloop.js +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// Flags: --expose-internals | 1 | 2 | 'use strict'; | 2 | 3 |
| 3 | 4 | const common = require('../common'); | 4 | 5 | const assert = require('assert'); | | 6 | +const { sleep } = require('internal/util'); | 5 | 7 |
| 6 | 8 | let called = false; | 7 | 9 | const t1 = setInterval(() => { | @@ -14,5 +16,5 @@ const t1 = setInterval(() => { | 14 | 16 | }, 10); | 15 | 17 |
| 16 | 18 | const t2 = setInterval(() => { | 17 | | - common.busyLoop(20); | | 19 | + sleep(20); | 18 | 20 | }, 10); |
Collapse file Copy file name to clipboardExpand all lines: test/sequential/test-timers-blocking-callback.js +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// Flags: --expose-internals | 1 | 2 | 'use strict'; | 2 | 3 |
| 3 | 4 | /* | | 25 | 26 |
| 26 | 27 | const common = require('../common'); | 27 | 28 | const assert = require('assert'); | | 29 | +const { sleep } = require('internal/util'); | 28 | 30 |
| 29 | 31 | const TIMEOUT = 100; | 30 | 32 |
| @@ -65,7 +67,7 @@ function blockingCallback(retry, callback) { | 65 | 67 | return callback(); | 66 | 68 | } else { | 67 | 69 | // Block by busy-looping to trigger the issue | 68 | | - common.busyLoop(TIMEOUT); | | 70 | + sleep(TIMEOUT); | 69 | 71 |
| 70 | 72 | timeCallbackScheduled = Date.now(); | 71 | 73 | setTimeout(blockingCallback.bind(null, retry, callback), TIMEOUT); | |
Collapse file Copy file name to clipboardExpand all lines: test/sequential/test-timers-set-interval-excludes-callback-duration.js +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// Flags: --expose-internals | 1 | 2 | 'use strict'; | 2 | | -const common = require('../common'); | | 3 | +require('../common'); | 3 | 4 | const assert = require('assert'); | | 5 | +const { sleep } = require('internal/util'); | 4 | 6 |
| 5 | 7 | let cntr = 0; | 6 | 8 | let first; | 7 | 9 | const t = setInterval(() => { | 8 | 10 | cntr++; | 9 | 11 | if (cntr === 1) { | 10 | | - common.busyLoop(100); | | 12 | + sleep(100); | 11 | 13 | // Ensure that the event loop passes before the second interval | 12 | 14 | setImmediate(() => assert.strictEqual(cntr, 1)); | 13 | 15 | first = Date.now(); | |
|