summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/HighResolutionTime
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-09-29 18:31:07 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-29 18:31:07 +0200
commit18cff5e0be2c2ac96e472e5d9dedd1303e036515 (patch)
tree0fbf5b7eda7122203d060ace15c9b70c599b5ea0 /Libraries/LibWeb/HighResolutionTime
parent62785b78724769f1dd01556778e9cb30d0a0bd1f (diff)
downloadserenity-18cff5e0be2c2ac96e472e5d9dedd1303e036515.zip
LibWeb: Implement performance.timeOrigin
This is the origin timestamp of the same monotonic clock used for the performance.now() timestamp. I got a little confused while implementing this, since the numbers are very low. That's because it uses the CLOCK_MONOTONIC system clock, which we start counting from 0 at boot. :^)
Diffstat (limited to 'Libraries/LibWeb/HighResolutionTime')
-rw-r--r--Libraries/LibWeb/HighResolutionTime/Performance.cpp6
-rw-r--r--Libraries/LibWeb/HighResolutionTime/Performance.h1
-rw-r--r--Libraries/LibWeb/HighResolutionTime/Performance.idl1
3 files changed, 8 insertions, 0 deletions
diff --git a/Libraries/LibWeb/HighResolutionTime/Performance.cpp b/Libraries/LibWeb/HighResolutionTime/Performance.cpp
index 0567260a63..77a905e9fd 100644
--- a/Libraries/LibWeb/HighResolutionTime/Performance.cpp
+++ b/Libraries/LibWeb/HighResolutionTime/Performance.cpp
@@ -44,6 +44,12 @@ Performance::~Performance()
{
}
+double Performance::time_origin() const
+{
+ auto origin = m_timer.origin_time();
+ return (origin.tv_sec * 1000.0) + (origin.tv_usec / 1000.0);
+}
+
void Performance::ref_event_target()
{
m_window.ref();
diff --git a/Libraries/LibWeb/HighResolutionTime/Performance.h b/Libraries/LibWeb/HighResolutionTime/Performance.h
index 588652400d..3d3bad0c65 100644
--- a/Libraries/LibWeb/HighResolutionTime/Performance.h
+++ b/Libraries/LibWeb/HighResolutionTime/Performance.h
@@ -42,6 +42,7 @@ public:
~Performance();
double now() const { return m_timer.elapsed(); }
+ double time_origin() const;
virtual void ref_event_target() override;
virtual void unref_event_target() override;
diff --git a/Libraries/LibWeb/HighResolutionTime/Performance.idl b/Libraries/LibWeb/HighResolutionTime/Performance.idl
index 33a0656167..4acb463f7a 100644
--- a/Libraries/LibWeb/HighResolutionTime/Performance.idl
+++ b/Libraries/LibWeb/HighResolutionTime/Performance.idl
@@ -1,3 +1,4 @@
interface Performance : EventTarget {
double now();
+ readonly attribute double timeOrigin;
}