--- title: performance.now() slug: Web/API/Performance/now translation_of: Web/API/Performance/now ---
{{APIRef("High Resolution Timing")}}

O método performance.now() retorna {{domxref("DOMHighResTimeStamp")}}, medido em milisegundos, com precisão de cinco milésimos de milissegundo (5 microsegundos).

O valor retornado representa o tempo decorrido desde o time origin (the {{domxref("PerformanceTiming.navigationStart")}} property). Em um web worker, o tempo inicial é o momento em que o contexto da execução(e.g. thread ou processo) é criado. Em uma janela, é o tempo em que o usuário iniciou a navegação neste documento. Tenha em mente que:

Sintaxe

t = performance.now();

Exemplo

var t0 = performance.now();
doSomething();
var t1 = performance.now();
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.");

Unlike other timing data available to JavaScript (for example Date.now), the timestamps returned by Performance.now() are not limited to one-millisecond resolution. Instead, they represent times as floating-point numbers with up to microsecond precision.

Also unlike Date.now(), the values returned by Performance.now() always increase at a constant rate, independent of the system clock (which might be adjusted manually or skewed by software like NTP). Otherwise, performance.timing.navigationStart + performance.now() will be approximately equal to Date.now().

Especificações

Specification Status Comment
{{SpecName('Highres Time Level 2', '#dom-performance-now', 'performance.now()')}} {{Spec2('Highres Time Level 2')}} Stricter definitions of interfaces and types.
{{SpecName('Highres Time', '#dom-performance-now', 'performance.now()')}} {{Spec2('Highres Time')}} Initial definition

Compatibilidade com navegadores

{{CompatibilityTable}}

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatChrome("20.0")}} {{property_prefix("webkit")}}
{{CompatChrome("24.0")}} [1]
{{CompatVersionUnknown}} {{CompatGeckoDesktop("15.0")}} 10.0 {{CompatOpera("15.0")}} {{CompatSafari("8.0")}}
on Web workers {{CompatChrome("33")}} {{CompatUnknown}} {{CompatGeckoDesktop("34.0")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
now() in a dedicated worker is now separate from the main context's now(). {{CompatUnknown}} {{CompatUnknown}} {{CompatGeckoDesktop("45.0")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
Feature Android Android Webview Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support {{CompatAndroid("4.0")}} {{CompatChrome("25.0")}} {{CompatVersionUnknown}} {{CompatGeckoMobile("15.0")}} 10.0 {{CompatNo}} 9 {{CompatChrome("25.0")}}
on Web workers {{CompatUnknown}} {{CompatVersionUnknown}} {{CompatUnknown}} {{CompatGeckoMobile("34.0")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatVersionUnknown}}
now() in a dedicated worker is now separate from the main context's now(). {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatGeckoMobile("45.0")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

[1] Windows versions of Chrome 20 through 33 return performance.now() only to millisecond precision.

Veja também