mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
LibWeb: Allow performance timestamps to have sub-millisecond precision
Rather than returning the number of whole elapsed milliseconds, we now return the number of elapsed nanoseconds divided by one million. This allows us to make use of the fractional part of the double that is returned.
This commit is contained in:
parent
05c571bf9b
commit
ee765e241e
2 changed files with 2 additions and 2 deletions
|
@ -52,7 +52,7 @@ JS::GCPtr<NavigationTiming::PerformanceTiming> Performance::timing()
|
||||||
|
|
||||||
double Performance::time_origin() const
|
double Performance::time_origin() const
|
||||||
{
|
{
|
||||||
return static_cast<double>(m_timer.origin_time().milliseconds());
|
return static_cast<double>(m_timer.origin_time().nanoseconds()) / 1e6;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/user-timing/#mark-method
|
// https://w3c.github.io/user-timing/#mark-method
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Performance final : public DOM::EventTarget {
|
||||||
public:
|
public:
|
||||||
virtual ~Performance() override;
|
virtual ~Performance() override;
|
||||||
|
|
||||||
double now() const { return static_cast<double>(m_timer.elapsed()); }
|
double now() const { return static_cast<double>(m_timer.elapsed_time().to_nanoseconds()) / 1e6; }
|
||||||
double time_origin() const;
|
double time_origin() const;
|
||||||
|
|
||||||
JS::GCPtr<NavigationTiming::PerformanceTiming> timing();
|
JS::GCPtr<NavigationTiming::PerformanceTiming> timing();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue