console.time

你可以启动一个计时器来跟踪某一个操作的占用时长。每一个计时器必须拥有唯一的名字,页面中最多能同时运行10,000个计时器。当以此计时器名字为参数调用 console.timeEnd() 时,浏览器将以毫秒为单位,输出对应计时器所经过的时间。

关于 Timers 的细节和例子请参考文档 console

Note: 此特性在 Web Worker 中可用。

语法

console.time(timerName);

参数

timerName
新计时器的名字。 用来标记这个计时器,作为参数调用 console.timeEnd()可以停止计时并将经过的时间在终端中打印出来.

规范

Specification Status Comment
Console API
console.time()
Living Standard Initial definition

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
timeChrome Full support 4Edge Full support 12Firefox Full support 10IE Full support 11Opera Full support YesSafari Full support 4WebView Android Full support 37Chrome Android Full support 18Firefox Android Full support 10Opera Android ? Safari iOS ? Samsung Internet Android Full support 1.0

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

参阅