我正在尝试计时fetch
电话。以下屏幕截图显示了chrome开发人员工具针对特定提取请求的显示时间。
可以看出,以红色标记的请求所花费的总时间为79 milliseconds
。看起来不错。
当我尝试使用性能api计时时,毫秒在超过100%163.46000001067296 ms
。怎么会这样
这是我在做什么:
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%。
我测量不正确吗?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句