/**
 * 获取页面性能数据
 * @returns
 */
function getPerformanceInfo() {
  var t = window.performance.timing;
  var m = window.performance.memory;
  return {
    dnsTime: t.domainLookupEnd - t.domainLookupStart,
    tcpTime: t.connectEnd - t.connectStart,
    reqTime: t.responseEnd - t.responseStart,
    domTime: t.domComplete - t.domInteractive,
    whiteTime: t.responseStart - t.navigationStart,
    domreadyTime: t.domContentLoadedEventEnd - t.navigationStart,
    onloadTime: t.loadEventEnd - t.navigationStart,
    jsHeapRatio: m ? Number.parseFloat((m.usedJSHeapSize / m.totalJSHeapSize * 100).toFixed(2)) : NaN
  };
}

export default getPerformanceInfo;
