MCPcopy Index your code
hub / github.com/nodejs/node / runAb

Function runAb

test/parallel/test-http-full-response.js:41–66  ·  view source on GitHub ↗
(opts, callback)

Source from the content-addressed store, hash-verified

39});
40
41function runAb(opts, callback) {
42 const command = `ab ${opts} http://127.0.0.1:${server.address().port}/`;
43 exec(command, common.mustCall(function(err, stdout, stderr) {
44 if (err) {
45 if (/ab|apr/i.test(stderr)) {
46 common.printSkipMessage(`problem spawning \`ab\`.\n${stderr}`);
47 process.reallyExit(0);
48 }
49 throw err;
50 }
51
52 let m = /Document Length:\s*(\d+) bytes/i.exec(stdout);
53 const documentLength = parseInt(m[1]);
54
55 m = /Complete requests:\s*(\d+)/i.exec(stdout);
56 const completeRequests = parseInt(m[1]);
57
58 m = /HTML transferred:\s*(\d+) bytes/i.exec(stdout);
59 const htmlTransferred = parseInt(m[1]);
60
61 assert.strictEqual(bodyLength, documentLength);
62 assert.strictEqual(completeRequests * documentLength, htmlTransferred);
63
64 if (callback) callback();
65 }));
66}
67
68server.listen(0, common.mustCall(function() {
69 runAb('-c 1 -n 10', common.mustCall(function() {

Callers 1

Calls 5

callbackFunction · 0.70
addressMethod · 0.65
execFunction · 0.50
testMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…