| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 79b2387 commit 30451d3
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,15 +28,10 @@ const epsilon = 50; | |||
| 28 | 28 | { | |
| 29 | 29 | const uptime1 = Date.now() - performance.timeOrigin; | |
| 30 | 30 | const uptime2 = performance.now(); | |
| 31 | - const uptime3 = process.uptime() * 1000; | ||
| 32 | 31 | assert(Math.abs(uptime1 - uptime2) < epsilon, | |
| 33 | 32 | `Date.now() - performance.timeOrigin (${uptime1}) - ` + | |
| 34 | 33 | `performance.now() (${uptime2}) = ` + | |
| 35 | 34 | `${uptime1 - uptime2} >= +- ${epsilon}`); | |
| 36 | - assert(Math.abs(uptime1 - uptime3) < epsilon, | ||
| 37 | - `Date.now() - performance.timeOrigin (${uptime1}) - ` + | ||
| 38 | - `process.uptime() * 1000 (${uptime3}) = ` + | ||
| 39 | - `${uptime1 - uptime3} >= +- ${epsilon}`); | ||
| 40 | 35 | } | |
| 41 | 36 | ||
| 42 | 37 | assert.strictEqual(performance.nodeTiming.name, 'node'); | |
@@ -58,8 +53,8 @@ function checkNodeTiming(timing) { | |||
| 58 | 53 | // performance.now() i.e. measures Node.js instance up time. | |
| 59 | 54 | assert.strictEqual(typeof timing.duration, 'number'); | |
| 60 | 55 | assert(timing.duration > 0, `timing.duration ${timing.duration} <= 0`); | |
| 61 | - assert(delta < 10, | ||
| 62 | - `now (${now}) - timing.duration (${timing.duration}) = ${delta} >= ${10}`); | ||
| 56 | + assert(delta < epsilon, | ||
| 57 | + `now (${now}) - timing.duration (${timing.duration}) = ${delta} >= ${epsilon}`); | ||
| 63 | 58 | ||
| 64 | 59 | // Check that the following fields do not change. | |
| 65 | 60 | assert.strictEqual(timing.startTime, initialTiming.startTime); | |
@@ -93,6 +88,18 @@ checkNodeTiming(initialTiming); | |||
| 93 | 88 | assert(nodeStart < testStartTime, | |
| 94 | 89 | `nodeStart ${nodeStart} >= ${testStartTime}`); | |
| 95 | 90 | ||
| 91 | + { | ||
| 92 | + // Due to https://github.com/nodejs/node/pull/46588, | ||
| 93 | + // The difference between process.uptime() and (Date.now() - performance.timeOrigin) | ||
| 94 | + // is roughly performance.nodeTiming.nodeStart | ||
| 95 | + const uptime1 = Date.now() - performance.timeOrigin; // now - process start time | ||
| 96 | + const uptime3 = process.uptime() * 1000; // now - node start time | ||
| 97 | + assert(Math.abs(uptime1 - uptime3 - nodeStart) < epsilon, | ||
| 98 | + `Date.now() - performance.timeOrigin (${uptime1}) - ` + | ||
| 99 | + `process.uptime() * 1000 (${uptime3}) = ` + | ||
| 100 | + `${uptime1 - uptime3} >= +- ${epsilon}`); | ||
| 101 | + } | ||
| 102 | + | ||
| 96 | 103 | assert.strictEqual(typeof v8Start, 'number'); | |
| 97 | 104 | assert(v8Start > 0, `v8Start ${v8Start} <= 0`); | |
| 98 | 105 | // V8 starts after the process starts. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments