GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: refactor test-gc-http-client-timeout · nodejs/node@fc5d1bd

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/sequential
    • test-gc-http-client-timeout.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/sequential/test-gc-http-client-timeout.js‎

Copy file name to clipboardExpand all lines: test/sequential/test-gc-http-client-timeout.js
+7-18Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
'use strict';
22
// 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.
54

65
const common = require('../common');
76
const onGC = require('../common/ongc');
87
const http = require('http');
9-
const os = require('os');
108

119
function serverHandler(req, res) {
1210
setTimeout(function() {
@@ -16,20 +14,16 @@ function serverHandler(req, res) {
1614
}, 100);
1715
}
1816

19-
const cpus = os.availableParallelism();
20-
const numRequests = 36;
21-
let createClients = true;
17+
const numRequests = 128;
2218
let done = 0;
23-
let count = 0;
2419
let countGC = 0;
2520

2621
const server = http.createServer(serverHandler);
27-
server.listen(0, common.mustCall(() => getAll(numRequests)));
22+
server.listen(0, common.mustCall(() => {
23+
getAll(numRequests);
24+
}));
2825

2926
function getAll(requestsRemaining) {
30-
if (!createClients)
31-
return;
32-
3327
if (requestsRemaining <= 0)
3428
return;
3529

@@ -41,15 +35,11 @@ function getAll(requestsRemaining) {
4135

4236
req.setTimeout(10, common.mustCall());
4337

44-
count++;
4538
onGC(req, { ongc });
4639

4740
setImmediate(getAll, requestsRemaining - 1);
4841
}
4942

50-
for (let i = 0; i < cpus; i++)
51-
getAll(numRequests);
52-
5343
function cb(res) {
5444
res.resume();
5545
done += 1;
@@ -63,10 +53,9 @@ setImmediate(status);
6353

6454
function status() {
6555
if (done > 0) {
66-
createClients = false;
6756
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) {
7059
server.close();
7160
return;
7261
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.