Home

performancenow

Performance.now() is a method of the Web Performance API that returns a high-resolution timestamp representing the number of milliseconds elapsed since the start of the navigation to the document. The returned value is a floating-point number with sub-millisecond precision and is monotonic, meaning it won’t go backward if the system clock changes.

The timestamp is relative to the document’s time origin, typically the navigationStart moment. To get an absolute

Usage is straightforward: const t0 = performance.now(); // code to measure const t1 = performance.now(); const duration = t1 - t0;

Compatibility and scope: Performance.now() is supported in all major browsers, including Chrome, Firefox, Safari, and Edge.

Limitations and notes: The value is relative to the page’s time origin and is intended for measuring

wall-clock
time,
you
can
add
performance.timeOrigin
to
performance.now().
Because
the
value
is
monotonic
and
not
affected
by
wall-clock
adjustments,
it
is
well
suited
for
measuring
elapsed
time,
durations,
and
performance
benchmarks
rather
than
for
presenting
a
real-time
clock.
This
API
is
available
on
the
window
object
in
browsers
and
in
workers
via
self.performance,
with
the
same
reference
point
for
a
given
execution
context.
It
is
accessible
in
scripts
running
on
a
page
as
well
as
inside
workers,
making
it
versatile
for
measuring
timing
across
different
threads.
durations,
not
for
giving
an
exact
clock
reading.
Precision
and
overhead
can
vary
by
device
and
browser,
and
the
timestamp
does
not
cross-origin
or
cross-process
boundaries
in
a
single,
unified
way.
For
robust
measurements,
repeated
trials
and
averaging
are
recommended.