美文网首页
MDN web docs——Performance API(翻译

MDN web docs——Performance API(翻译

作者: 维仔_411d | 来源:发表于2019-12-26 14:59 被阅读0次

    Web technology for developers > Web APIs > Performance API
    高精度时间(High Resolution Time)标准定义了一个Performance接口,来测量应用(application)内的客户端时延(latency)。Performance接口是高精度的,它可以精确到微秒(受硬件和软件限制)。Performance接口提供很多用例,如计算帧率(在动画中可能很重要)和基准测试(如加载资源用时)(and benchmarking(such as the time to load a resource))
    平台的系统时钟容易受到多种因素影响(例如NTP调整)(网络时间协议,英文名称:Network Time Protocol(NTP)是用来使计算机时间同步化的一种协议,它可以使计算机对其服务器或时钟源(如石英钟,GPS等等)做同步化,它可以提供高精准度的时间校正(LAN上与标准间差小于1毫秒,WAN上几十毫秒),且可介由加密确认的方式来防止恶毒的协议攻击。NTP的目的是在无序的Internet环境中提供精确和健壮的时间服务。),接口提供单调时钟(时钟时钟增长),这样PerformanceAPI定义了DOMHightResTimeStamp类型,而不是使用Date.now();

    方法:

    now():返回DOMHighResTimeStamp,值取决于导航开始和范围。若范围是窗口,则值是当前浏览环境创建的时间,若范围是工作进程,则值为工作进程创建的时间(The now() method returns a DOMHightResTimeStamp whose value that depends on the navigation start and scope. If the scope is a window, the value is the time the browser context was created and if the scope is a worker, the value is the time the worker was created)
    toJSON():返回Performance对象的序列化,仅序列化那些能够被序列化的属性

    属性

    timing: 返回一个PerformanceTiming对象,其中包含时延相关的性能信息,如导航的开始时间,跳转的开始、结束时间,response的开始结束时间等
    navigation: 返回一个PerformanceNavigation对象,表示在给出的当前浏览环境发生的导航的类型,例如当前页面是由历史记录导航到的或 当前页面是通过链接导航到的(representing the type of navigation that occurs in the given browsing context, such ad the page was navigated to from history,the page was navigated to by following a link)。

    接口

    Performance

    提供的方法和属性包含 当前页面时间相关的性能信息(Provides methods and properties containing timing-related performance information for the given page);

    PerformanceEntry

    提供的方法和属性封装单一的性能指标,是性能时间线的一部分(Provides methods and properties the encapsulate a single performance metric that is part of the performance timeline);

    PerformanceMark

    performance entries 类型为mark的抽象接口,通过调用performance.mark() 在浏览器的性能时间线上增加一个名为DOMHighResTimeStamp(the mark)可以创建这种类型的entry;(An abstract interface for performance entries with an enty type of 'mark'.Enties of this type are created by calling performance.mark() to add a named DOMHightResTimeStamp(the mark) to the browser's performance timeline)

    PerformanceMeasure

    performance entries 类型为measure的抽象接口,通过调用performance.measure() 在浏览器的性能时间线上两个标记之间增加一个名为DOMHighResTimeStamp(the measure)可以创建这种类型的entry;(An abstract interface for performance entries with an enty type of 'measure'.Entries of this type are created by calling performance.measure() to add a named DOMHightResTimeStamp(the measure) between two marks to the browser's performance timeline.)

    PerformanceObserver

    提供的方法和属性 用来观察性能测量事件,当新的performance entries被记录在浏览器的性能时间线上时会得到通知 ;(Provides methods and properties used to observe performance measurement events and be notified of new performance entries as they are recorded in the browser's performance timeline.)

    PerformanceFrameTiming (Draft草案)

    提供的方法和属性包含浏览器时间循环的帧计时数据(Provides methods and properties containing frame timing data about the browser's event loop.) ;

    PerformanceNavigationTiming

    提供的方法和属性 用来存储和检索与浏览器文档导航事件相关的高精度时间或指标 ;(Provides methods and properties to store and retrieve hight resolution timestamps or metrics regarding the browser's document navigation events)

    PerformanceResourceTiming

    提供的方法和属性 来检索和分析 与应用内的资源下载相关的详细网络时间数据 ;(Provides methods and properties for retrieving and analyzing detailed network timing data regarding the loading of an application's resources.)

    相关文章

      网友评论

          本文标题:MDN web docs——Performance API(翻译

          本文链接:https://www.haomeiwen.com/subject/wdzkoctx.html