| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2b1cb3b commit 149c209
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,44 +10,40 @@ function serverHandler(req, res) { | |||
| 10 | 10 | } | |
| 11 | 11 | ||
| 12 | 12 | const http = require('http'); | |
| 13 | - const todo = 500; | ||
| 13 | + const todo = 300; | ||
| 14 | 14 | let done = 0; | |
| 15 | 15 | let count = 0; | |
| 16 | 16 | let countGC = 0; | |
| 17 | 17 | ||
| 18 | 18 | console.log(`We should do ${todo} requests`); | |
| 19 | 19 | ||
| 20 | 20 | const server = http.createServer(serverHandler); | |
| 21 | - server.listen(0, getall); | ||
| 22 | - | ||
| 21 | + server.listen(0, common.mustCall(() => { | ||
| 22 | + for (let i = 0; i < 15; i++) | ||
| 23 | + getall(); | ||
| 24 | + })); | ||
| 23 | 25 | ||
| 24 | 26 | function getall() { | |
| 25 | - if (count >= todo) | ||
| 27 | + if (count === todo) | ||
| 26 | 28 | return; | |
| 27 | 29 | ||
| 28 | - (function() { | ||
| 29 | - function cb(res) { | ||
| 30 | - res.resume(); | ||
| 31 | - console.error('in cb'); | ||
| 32 | - done += 1; | ||
| 33 | - res.on('end', global.gc); | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - const req = http.get({ | ||
| 37 | - hostname: 'localhost', | ||
| 38 | - pathname: '/', | ||
| 39 | - port: server.address().port | ||
| 40 | - }, cb); | ||
| 30 | + const req = http.get({ | ||
| 31 | + hostname: 'localhost', | ||
| 32 | + pathname: '/', | ||
| 33 | + port: server.address().port | ||
| 34 | + }, cb); | ||
| 41 | 35 | ||
| 42 | - count++; | ||
| 43 | - common.onGC(req, { ongc }); | ||
| 44 | - })(); | ||
| 36 | + count++; | ||
| 37 | + common.onGC(req, { ongc }); | ||
| 45 | 38 | ||
| 46 | 39 | setImmediate(getall); | |
| 47 | 40 | } | |
| 48 | 41 | ||
| 49 | - for (let i = 0; i < 10; i++) | ||
| 50 | - getall(); | ||
| 42 | + function cb(res) { | ||
| 43 | + res.resume(); | ||
| 44 | + done += 1; | ||
| 45 | + res.on('end', global.gc); | ||
| 46 | + } | ||
| 51 | 47 | ||
| 52 | 48 | function ongc() { | |
| 53 | 49 | countGC++; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments