Javascript 比较performance API和chrome'的计时结果时的差异;s开发工具

Javascript 比较performance API和chrome'的计时结果时的差异;s开发工具,javascript,performance,fetch,google-chrome-devtools,Javascript,Performance,Fetch,Google Chrome Devtools,我正在尝试计时获取呼叫。下面的屏幕截图显示了chrome developer工具针对特定获取请求显示的时间 从红色标记的请求可以看出,它花费的总时间是79毫秒。看起来不错 当我尝试使用计时时,毫秒在163.46000001067296 ms时超过100%。怎么会这样 以下是我正在做的: loadInitVariables() { const queryString = this.formQueryString(this.queryStringParams);

我正在尝试计时
获取
呼叫。下面的屏幕截图显示了chrome developer工具针对特定获取请求显示的时间

从红色标记的请求可以看出,它花费的总时间是
79毫秒
。看起来不错

当我尝试使用计时时,毫秒在
163.46000001067296 ms时超过100%
。怎么会这样

以下是我正在做的:

    loadInitVariables() {
        const queryString = this.formQueryString(this.queryStringParams);
        const t0 = performance.now(); // TIMESTAMP ONE @ T0
        return fetch(`${this.initVariablesPath}${queryString}`, {
            method: "get",
            headers: { "Content-Type": "application/json" },
        })
            .then(response => {
                const t1 = performance.now(); // TIMESTAMP 2 @ T1
                log.debug(`Loaded init vars in ${t1 - t0} ms.`);
                return response.json();
            })
    }
为什么会有这种差异?如果它可能是几毫秒,即+10-+20,那就没问题了,但它超过了100%


我的测量是否不正确?

考虑这个例子,网络选项卡中显示的时间包括查询、启动、暂停时间(如果有)、发送和等待

性能的时差。现在
似乎排除了这些数字


有没有办法只获取
TTFB
?@SuhailGupta不确定是否可以帮助
var TTFB=navigationEntries.responseStart-navigationEntries.requestStart