/* * Copyright (c) 2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include #include namespace Web::HighResolutionTime { Performance::Performance(HTML::Window& window) : DOM::EventTarget(window.realm()) , m_window(window) { set_prototype(&Bindings::cached_web_prototype(realm(), "Performance")); m_timer.start(); } Performance::~Performance() = default; void Performance::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); visitor.visit(m_window.ptr()); visitor.visit(m_timing.ptr()); } JS::GCPtr Performance::timing() { if (!m_timing) m_timing = heap().allocate(realm(), *m_window); return m_timing; } double Performance::time_origin() const { auto origin = m_timer.origin_time(); return (origin.tv_sec * 1000.0) + (origin.tv_usec / 1000.0); } }