| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6a58054 commit 41d1e68
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,10 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | // Flags: --expose-gc | |
| 3 | - // just like test-gc-http-client.js, | ||
| 4 | - // but with a timeout set | ||
| 3 | + // Like test-gc-http-client.js, but with a timeout set. | ||
| 5 | 4 | ||
| 6 | 5 | const common = require('../common'); | |
| 7 | 6 | const onGC = require('../common/ongc'); | |
| 8 | 7 | const http = require('http'); | |
| 9 | - const os = require('os'); | ||
| 10 | 8 | ||
| 11 | 9 | function serverHandler(req, res) { | |
| 12 | 10 | setTimeout(function() { | |
@@ -16,20 +14,16 @@ function serverHandler(req, res) { | |||
| 16 | 14 | }, 100); | |
| 17 | 15 | } | |
| 18 | 16 | ||
| 19 | - const cpus = os.availableParallelism(); | ||
| 20 | - const numRequests = 36; | ||
| 21 | - let createClients = true; | ||
| 17 | + const numRequests = 128; | ||
| 22 | 18 | let done = 0; | |
| 23 | - let count = 0; | ||
| 24 | 19 | let countGC = 0; | |
| 25 | 20 | ||
| 26 | 21 | const server = http.createServer(serverHandler); | |
| 27 | - server.listen(0, common.mustCall(() => getAll(numRequests))); | ||
| 22 | + server.listen(0, common.mustCall(() => { | ||
| 23 | + getAll(numRequests); | ||
| 24 | + })); | ||
| 28 | 25 | ||
| 29 | 26 | function getAll(requestsRemaining) { | |
| 30 | - if (!createClients) | ||
| 31 | - return; | ||
| 32 | - | ||
| 33 | 27 | if (requestsRemaining <= 0) | |
| 34 | 28 | return; | |
| 35 | 29 | ||
@@ -41,15 +35,11 @@ function getAll(requestsRemaining) { | |||
| 41 | 35 | ||
| 42 | 36 | req.setTimeout(10, common.mustCall()); | |
| 43 | 37 | ||
| 44 | - count++; | ||
| 45 | 38 | onGC(req, { ongc }); | |
| 46 | 39 | ||
| 47 | 40 | setImmediate(getAll, requestsRemaining - 1); | |
| 48 | 41 | } | |
| 49 | 42 | ||
| 50 | - for (let i = 0; i < cpus; i++) | ||
| 51 | - getAll(numRequests); | ||
| 52 | - | ||
| 53 | 43 | function cb(res) { | |
| 54 | 44 | res.resume(); | |
| 55 | 45 | done += 1; | |
@@ -63,10 +53,9 @@ setImmediate(status); | |||
| 63 | 53 | ||
| 64 | 54 | function status() { | |
| 65 | 55 | if (done > 0) { | |
| 66 | - createClients = false; | ||
| 67 | 56 | global.gc(); | |
| 68 | - console.log(`done/collected/total: ${done}/${countGC}/${count}`); | ||
| 69 | - if (countGC === count) { | ||
| 57 | + console.log(`done/collected/total: ${done}/${countGC}/${numRequests}`); | ||
| 58 | + if (countGC === numRequests) { | ||
| 70 | 59 | server.close(); | |
| 71 | 60 | return; | |
| 72 | 61 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments