zoukankan      html  css  js  c++  java
  • 统计网页加载时间

    Web performance APIs

    可以得到各种时间,如dns解析时间,连接时间、跳转时间、加载时间等指标。
    这些API需要在页面加载完成后才能使用,需要在window.onload事件中读取各种数据,因为很多值必须在页面完全加载之后才能得出。

    • 页面加载API

    window.performance.timing 返回一个只读的PerformanceTiming对象,用于分析页面整体性能指标,常用的统计数据如下:

    • DNS查询耗时 :domainLookupEnd - domainLookupStart
    • TCP链接耗时 :connectEnd - connectStart
    • request请求耗时 :responseEnd - responseStart
    • 解析dom树耗时 : domComplete- domInteractive
    • 白屏时间 :responseStart - navigationStart
    • domready时间 :domContentLoadedEventEnd - navigationStart
    • onload时间 :loadEventEnd - navigationStart

    其中navigationStart为准备加载新页面的起始时间,loadEventEnd文档触发load事件结束时间

    • 资源加载API

    window.performance.getEntries() 显示所有静态资源的加载时间
    window.performance.getEntriesByName() 获取相应名字资源的加载时间
    window.performance.getEntriesByType() 获取相应类型资源的加载时间

  • 相关阅读:
    C++计算器项目的初始部分
    视频教程自学计划
    1001.A+B Format (20)解题描述
    成为理想的自己
    Sample Join Analysis
    Sample MultipleFileWordcount CombineFileInputFormat
    FileOutputFormat
    Combine small files to Sequence file
    FileInputFormat
    Sample: Write And Read data from HDFS with java API
  • 原文地址:https://www.cnblogs.com/wangxirui/p/13343992.html
Copyright © 2011-2022 走看看