| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 76ebae4 commit 231af88
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,9 +34,10 @@ function workerOnMetricsMsg(msg) { | |||
| 34 | 34 | } | |
| 35 | 35 | ||
| 36 | 36 | if (msg.cmd === 'spin') { | |
| 37 | + const elu = eventLoopUtilization(); | ||
| 37 | 38 | const t = now(); | |
| 38 | 39 | while (now() - t < msg.dur); | |
| 39 | - return this.postMessage(eventLoopUtilization()); | ||
| 40 | + return this.postMessage(eventLoopUtilization(elu)); | ||
| 40 | 41 | } | |
| 41 | 42 | } | |
| 42 | 43 | ||
@@ -50,12 +51,13 @@ let workerELU; | |||
| 50 | 51 | if (eventLoopUtilization().idle <= 0) | |
| 51 | 52 | return setTimeout(mustCall(r), 5); | |
| 52 | 53 | ||
| 54 | + mainElu = eventLoopUtilization(); | ||
| 55 | + | ||
| 53 | 56 | worker = new Worker(__filename, { argv: [ 'iamalive' ] }); | |
| 54 | 57 | metricsCh = new MessageChannel(); | |
| 55 | 58 | worker.postMessage({ metricsCh: metricsCh.port1 }, [ metricsCh.port1 ]); | |
| 56 | 59 | ||
| 57 | 60 | workerELU = worker.performance.eventLoopUtilization; | |
| 58 | - mainElu = eventLoopUtilization(); | ||
| 59 | 61 | metricsCh.port2.once('message', mustCall(checkWorkerIdle)); | |
| 60 | 62 | metricsCh.port2.postMessage({ cmd: 'elu' }); | |
| 61 | 63 | // Make sure it's still safe to call eventLoopUtilization() after the worker | |
@@ -66,15 +68,10 @@ let workerELU; | |||
| 66 | 68 | })); | |
| 67 | 69 | })(); | |
| 68 | 70 | ||
| 69 | - | ||
| 70 | 71 | function checkWorkerIdle(wElu) { | |
| 71 | - const tmpMainElu = eventLoopUtilization(mainElu); | ||
| 72 | 72 | const perfWorkerElu = workerELU(); | |
| 73 | - const eluDiff = eventLoopUtilization(perfWorkerElu, mainElu); | ||
| 73 | + const tmpMainElu = eventLoopUtilization(mainElu); | ||
| 74 | 74 | ||
| 75 | - assert.strictEqual(idleActive(eluDiff), | ||
| 76 | - (perfWorkerElu.active - mainElu.active) + | ||
| 77 | - (perfWorkerElu.idle - mainElu.idle)); | ||
| 78 | 75 | assert.ok(idleActive(wElu) > 0, `${idleActive(wElu)} <= 0`); | |
| 79 | 76 | assert.ok(idleActive(workerELU(wElu)) > 0, | |
| 80 | 77 | `${idleActive(workerELU(wElu))} <= 0`); | |
@@ -104,8 +101,9 @@ function checkWorkerActive() { | |||
| 104 | 101 | const w2 = workerELU(w); | |
| 105 | 102 | ||
| 106 | 103 | assert.ok(w2.active >= 50, `${w2.active} < 50`); | |
| 107 | - assert.ok(idleActive(wElu) > idleActive(w2), | ||
| 108 | - `${idleActive(wElu)} <= ${idleActive(w2)}`); | ||
| 104 | + assert.ok(wElu.active >= 50, `${wElu.active} < 50`); | ||
| 105 | + assert.ok(idleActive(wElu) < idleActive(w2), | ||
| 106 | + `${idleActive(wElu)} >= ${idleActive(w2)}`); | ||
| 109 | 107 | ||
| 110 | 108 | metricsCh.port2.postMessage({ cmd: 'close' }); | |
| 111 | 109 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments