简体   繁体   English

如何用微秒精度测量Safari中JavaScript函数的执行时间?

[英]How to measure execution time of JavaScript function in Safari with microsecond precision?

As in title. 如标题。 I know about "High Resolution Time" http://www.w3.org/TR/hr-time/ , but it doesn't work in Safari. 我知道“高分辨率时间” http://www.w3.org/TR/hr-time/ ,但它在Safari中不起作用。 Are there any other options? 还有其他选择吗?

EDIT: 编辑:
I need to measure time of single SELECT in WebSQL. 我需要在WebSQL中测量单个SELECT的时间。 Now it's time is about 1-2 millisecond. 现在它的时间大约是1-2毫秒。 I need more precision then that. 我需要更高的精度。

EDIT 2: I developing iOS app with PhoneGap, so I can't change browser. 编辑2:我用PhoneGap开发iOS应用程序,所以我无法更改浏览器。 It have to be Safari. 它必须是Safari。

Using the Console API's time() and timeEnd() methods I seem to get better precision: 使用Console API的time()和timeEnd()方法,我似乎获得了更好的精度:

> console.time('a')
> console.timeEnd('a')
[Debug] a: 5895.467ms

See the Safari documentation for details: https://developer.apple.com/library/archive/documentation/AppleApplications/Conceptual/Safari_Developer_Guide/Console/Console.html 有关详细信息,请参阅Safari文档: https//developer.apple.com/library/archive/documentation/AppleApplications/Conceptual/Safari_Developer_Guide/Console/Console.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM