tailor.on('response', request => { if (primaryOverhead > 0 && requests.has(request)) { const startTime = requests.get(request); const timeToHeaders = getMillisecs(process.hrtime(startTime)); updateTailorOverhead(timeToHeaders, primaryOverhead); } });
tailor.on('fragment:start', (request, fragment) => { fragments.set(fragment, process.hrtime()); });
tailor.on('fragment:response', (request, fragment) => { const startTime = fragments.get(fragment); if (fragment.primary) { primaryOverhead = getMillisecs(process.hrtime(startTime)); } });
const now = () => { let now = process.hrtime(); return now[0] * 1e3 + now[1] / 1e6; }
// Returns a high resolution time (if possible) in milliseconds export function now(): number { if (window && window.performance) { return window.performance.now(); } else if (process && process.hrtime) { const [seconds, nanoseconds] = process.hrtime(); const secInMS = seconds * MS_PER_S; const nSecInMS = nanoseconds / NS_PER_MS; return secInMS + nSecInMS; } else { return Date.now(); } }
value: formatTime(process.hrtime(bot.managers.stats.get('start-time'))) },
); stats.set('start-time', process.hrtime());
const client = (options, callback) => { const timings = { startTime: process.hrtime(), dnsLookupTime: undefined, tcpConnectionTime: undefined, const request = usedProtocol.request(options, (res) => { res.once('data', () => { timings.responseBodyStartTime = process.hrtime(); }); timings.responseBodyEndTime = process.hrtime(); callback(null, { body: response, timings.dnsLookupTime = process.hrtime(); }); timings.tcpConnectionTime = process.hrtime(); }) timings.tlsHandshakeTime = process.hrtime(); }); socket.on('timeout', () => {
// Tailor Events to collect Metrics tailor.on('start', request => { requests.set(request, process.hrtime()); });