| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3d0a3fe commit 03c0819
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,18 +17,22 @@ function serverHandler(req, res) { | |||
| 17 | 17 | } | |
| 18 | 18 | ||
| 19 | 19 | const cpus = os.cpus().length; | |
| 20 | + const numRequests = 36; | ||
| 20 | 21 | let createClients = true; | |
| 21 | 22 | let done = 0; | |
| 22 | 23 | let count = 0; | |
| 23 | 24 | let countGC = 0; | |
| 24 | 25 | ||
| 25 | 26 | const server = http.createServer(serverHandler); | |
| 26 | - server.listen(0, common.mustCall(getAll)); | ||
| 27 | + server.listen(0, common.mustCall(() => getAll(numRequests))); | ||
| 27 | 28 | ||
| 28 | - function getAll() { | ||
| 29 | + function getAll(requestsRemaining) { | ||
| 29 | 30 | if (!createClients) | |
| 30 | 31 | return; | |
| 31 | 32 | ||
| 33 | + if (requestsRemaining <= 0) | ||
| 34 | + return; | ||
| 35 | + | ||
| 32 | 36 | const req = http.get({ | |
| 33 | 37 | hostname: 'localhost', | |
| 34 | 38 | pathname: '/', | |
@@ -40,11 +44,11 @@ function getAll() { | |||
| 40 | 44 | count++; | |
| 41 | 45 | onGC(req, { ongc }); | |
| 42 | 46 | ||
| 43 | - setImmediate(getAll); | ||
| 47 | + setImmediate(getAll, requestsRemaining - 1); | ||
| 44 | 48 | } | |
| 45 | 49 | ||
| 46 | 50 | for (let i = 0; i < cpus; i++) | |
| 47 | - getAll(); | ||
| 51 | + getAll(numRequests); | ||
| 48 | 52 | ||
| 49 | 53 | function cb(res) { | |
| 50 | 54 | res.resume(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,6 +15,7 @@ function serverHandler(req, res) { | |||
| 15 | 15 | } | |
| 16 | 16 | ||
| 17 | 17 | const http = require('http'); | |
| 18 | + const numRequests = 36; | ||
| 18 | 19 | let createClients = true; | |
| 19 | 20 | let done = 0; | |
| 20 | 21 | let count = 0; | |
@@ -23,22 +24,26 @@ let countGC = 0; | |||
| 23 | 24 | const server = http.createServer(serverHandler); | |
| 24 | 25 | server.listen(0, common.mustCall(() => { | |
| 25 | 26 | for (let i = 0; i < cpus; i++) | |
| 26 | - getAll(); | ||
| 27 | + getAll(numRequests); | ||
| 27 | 28 | })); | |
| 28 | 29 | ||
| 29 | - function getAll() { | ||
| 30 | - if (createClients) { | ||
| 31 | - const req = http.get({ | ||
| 32 | - hostname: 'localhost', | ||
| 33 | - pathname: '/', | ||
| 34 | - port: server.address().port | ||
| 35 | - }, cb).on('error', onerror); | ||
| 30 | + function getAll(requestsRemaining) { | ||
| 31 | + if (!createClients) | ||
| 32 | + return; | ||
| 36 | 33 | ||
| 37 | - count++; | ||
| 38 | - onGC(req, { ongc }); | ||
| 34 | + if (requestsRemaining <= 0) | ||
| 35 | + return; | ||
| 39 | 36 | ||
| 40 | - setImmediate(getAll); | ||
| 41 | - } | ||
| 37 | + const req = http.get({ | ||
| 38 | + hostname: 'localhost', | ||
| 39 | + pathname: '/', | ||
| 40 | + port: server.address().port | ||
| 41 | + }, cb).on('error', onerror); | ||
| 42 | + | ||
| 43 | + count++; | ||
| 44 | + onGC(req, { ongc }); | ||
| 45 | + | ||
| 46 | + setImmediate(getAll, requestsRemaining - 1); | ||
| 42 | 47 | } | |
| 43 | 48 | ||
| 44 | 49 | function cb(res) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,6 +13,7 @@ function serverHandler(req, res) { | |||
| 13 | 13 | } | |
| 14 | 14 | ||
| 15 | 15 | const http = require('http'); | |
| 16 | + const numRequests = 36; | ||
| 16 | 17 | let createClients = true; | |
| 17 | 18 | let done = 0; | |
| 18 | 19 | let count = 0; | |
@@ -21,13 +22,16 @@ let countGC = 0; | |||
| 21 | 22 | const server = http.createServer(serverHandler); | |
| 22 | 23 | server.listen(0, common.mustCall(() => { | |
| 23 | 24 | for (let i = 0; i < cpus; i++) | |
| 24 | - getAll(); | ||
| 25 | + getAll(numRequests); | ||
| 25 | 26 | })); | |
| 26 | 27 | ||
| 27 | - function getAll() { | ||
| 28 | + function getAll(requestsRemaining) { | ||
| 28 | 29 | if (!createClients) | |
| 29 | 30 | return; | |
| 30 | 31 | ||
| 32 | + if (requestsRemaining <= 0) | ||
| 33 | + return; | ||
| 34 | + | ||
| 31 | 35 | const req = http.get({ | |
| 32 | 36 | hostname: 'localhost', | |
| 33 | 37 | pathname: '/', | |
@@ -37,7 +41,7 @@ function getAll() { | |||
| 37 | 41 | count++; | |
| 38 | 42 | onGC(req, { ongc }); | |
| 39 | 43 | ||
| 40 | - setImmediate(getAll); | ||
| 44 | + setImmediate(getAll, requestsRemaining - 1); | ||
| 41 | 45 | } | |
| 42 | 46 | ||
| 43 | 47 | function cb(res) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments