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

Function main

benchmark/http/end-vs-write-end.js:21–60  ·  view source on GitHub ↗
({ len, type, method, c, duration })

Source from the content-addressed store, hash-verified

19});
20
21function main({ len, type, method, c, duration }) {
22 const http = require('http');
23 let chunk;
24 switch (type) {
25 case 'buf':
26 chunk = Buffer.alloc(len, 'x');
27 break;
28 case 'utf':
29 chunk = 'ü'.repeat(len / 2);
30 break;
31 case 'asc':
32 chunk = 'a'.repeat(len);
33 break;
34 }
35
36 function write(res) {
37 res.write(chunk);
38 res.end();
39 }
40
41 function end(res) {
42 res.end(chunk);
43 }
44
45 const fn = method === 'write' ? write : end;
46
47 const server = http.createServer((req, res) => {
48 fn(res);
49 });
50
51 server.listen(0, () => {
52 bench.http({
53 connections: c,
54 duration,
55 port: server.address().port,
56 }, () => {
57 server.close();
58 });
59 });
60}

Callers

nothing calls this directly

Calls 7

allocMethod · 0.80
listenMethod · 0.80
httpMethod · 0.80
addressMethod · 0.65
closeMethod · 0.65
requireFunction · 0.50
fnFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…