lib/helpers/timings.js
function getTimings (eventTimes) {
    return {
        // There is no DNS lookup with IP address, can be null
        dnsLookup: getHrTimeDurationInMs(
            eventTimes.startAt,
            eventTimes.dnsLookupAt
        ),
        tcpConnection: getHrTimeDurationInMs(
            eventTimes.dnsLookupAt || eventTimes.startAt,
            eventTimes.tcpConnectionAt
        ),
        // There is no TLS handshake without https, can be null
        tlsHandshake: getHrTimeDurationInMs(
            eventTimes.tcpConnectionAt,
            eventTimes.tlsHandshakeAt
        ),
        firstByte: getHrTimeDurationInMs((
            // There is no TLS/TCP Connection with keep-alive connection
            eventTimes.tlsHandshakeAt || eventTimes.tcpConnectionAt ||
                eventTimes.startAt),
            eventTimes.firstByteAt
        ),
        contentTransfer: getHrTimeDurationInMs(
            eventTimes.firstByteAt,
            eventTimes.endAt
        ),
        total: getHrTimeDurationInMs(eventTimes.startAt, eventTimes.endAt)
    };
}
function getTimings (eventTimes) {
    return {
        // There is no DNS lookup with IP address, can be null
        dnsLookup: getHrTimeDurationInMs(
            eventTimes.startAt,
            eventTimes.dnsLookupAt
        ),
        tcpConnection: getHrTimeDurationInMs(
            eventTimes.dnsLookupAt || eventTimes.startAt,
            eventTimes.tcpConnectionAt
        ),
        // There is no TLS handshake without https, can be null
        tlsHandshake: getHrTimeDurationInMs(
            eventTimes.tcpConnectionAt,
            eventTimes.tlsHandshakeAt
        ),
        firstByte: getHrTimeDurationInMs((
            // There is no TLS/TCP Connection with keep-alive connection
            eventTimes.tlsHandshakeAt || eventTimes.tcpConnectionAt ||
                eventTimes.startAt),
            eventTimes.firstByteAt
        ),
        contentTransfer: getHrTimeDurationInMs(
            eventTimes.firstByteAt,
            eventTimes.endAt
        ),
        total: getHrTimeDurationInMs(eventTimes.startAt, eventTimes.endAt)
    };
}
function getTimings ( eventTimes ) { return { // There is no DNS lookup with IP address, can be null dnsLookup : getHrTimeDurationInMs ( eventTimes . startAt , eventTimes . dnsLookupAt ) , tcpConnection : getHrTimeDurationInMs ( eventTimes . dnsLookupAt || eventTimes . startAt , eventTimes . tcpConnectionAt ) , // There is no TLS handshake without https, can be null tlsHandshake : getHrTimeDurationInMs ( eventTimes . tcpConnectionAt , eventTimes . tlsHandshakeAt ) , firstByte : getHrTimeDurationInMs ( ( // There is no TLS/TCP Connection with keep-alive connection eventTimes . tlsHandshakeAt || eventTimes . tcpConnectionAt || eventTimes . startAt ) , eventTimes . firstByteAt ) , contentTransfer : getHrTimeDurationInMs ( eventTimes . firstByteAt , eventTimes . endAt ) , total : getHrTimeDurationInMs ( eventTimes . startAt , eventTimes . endAt ) } ; }
Calculates HTTP timings
@function getTimings
@param {Object} eventTimes - Timings
@param {Number} eventTimes.startAt - Request started
@param {Number|undefined} eventTimes.dnsLookupAt - DNS resolved
@param {Number} eventTimes.tcpConnectionAt - TCP connection estabilished
@param {Number|undefined} eventTimes.tlsHandshakeAt - TLS handshake finished
@param {Number} eventTimes.firstByteAt - First byte arrived
@param {Number} eventTimes.endAt - Request ended
@returns {Object} timings - { dnsLookup, tcpConnection, tlsHandshake,
firstByte, contentTransfer, total }
Calculates HTTP timings