1
我目前正在保存一些httpCall的持續時間來分析我的web應用程序的性能。我使用window.performance.getEntries()並只獲得我需要的調用。與window.performance的http調用的大小
所有工作都很完美,但我想獲得這個保存的電話的大小。這可以使用window.performance?
我目前正在保存一些httpCall的持續時間來分析我的web應用程序的性能。我使用window.performance.getEntries()並只獲得我需要的調用。與window.performance的http調用的大小
所有工作都很完美,但我想獲得這個保存的電話的大小。這可以使用window.performance?
對於誰想做同樣的事情比我的人,我發現了一個文檔中的MDN談論的是:
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/encodedBodySize
的方法存在,但瀏覽器都沒有付諸實施。
這裏的代碼從MDN樣品:
function log_sizes(perfEntry){
// Check for support of the PerformanceEntry.*size properties and print their values
// if supported.
if ("decodedBodySize" in perfEntry)
console.log("decodedBodySize = " + perfEntry.decodedBodySize);
else
console.log("decodedBodySize = NOT supported");
if ("encodedBodySize" in perfEntry)
console.log("encodedBodySize = " + perfEntry.encodedBodySize);
else
console.log("encodedBodySize = NOT supported");
if ("transferSize" in perfEntry)
console.log("transferSize = " + perfEntry.transferSize);
else
console.log("transferSize = NOT supported");
}
function check_PerformanceEntries() {
// Use getEntriesByType() to just get the "resource" events
var p = performance.getEntriesByType("resource");
for (var i=0; i < p.length; i++) {
log_sizes(p[i]);
}
}