Http Timings

[Solved] Http Timings | Php - Code Explorer | yomemimo.com
Question : http timings

Answered by : jealous-jay-llz7ke6etu5h

const timings = { // use process.hrtime() as it's not a subject of clock drift startAt: process.hrtime(), dnsLookupAt: undefined, tcpConnectionAt: undefined, tlsHandshakeAt: undefined, firstByteAt: undefined, endAt: undefined } const req = http.request({ ... }, (res) => { res.once('readable', () => { timings.firstByteAt = process.hrtime() }) res.on('data', (chunk) => { responseBody += chunk }) res.on('end', () => { timings.endAt = process.hrtime() }) }) req.on('socket', (socket) => { socket.on('lookup', () => { timings.dnsLookupAt = process.hrtime() }) socket.on('connect', () => { timings.tcpConnectionAt = process.hrtime() }) socket.on('secureConnect', () => { timings.tlsHandshakeAt = process.hrtime() }) })

Source : https://blog.risingstack.com/measuring-http-timings-node-js/ | Last Update : Thu, 12 Oct 23

Answers related to http timings

Code Explorer Popular Question For Php