/* * Copyright (c) 2020, Andreas Kling * Copyright (c) 2023, Luke Wilde * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Web::HighResolutionTime { class Performance final : public DOM::EventTarget { WEB_PLATFORM_OBJECT(Performance, DOM::EventTarget); public: virtual ~Performance() override; double now() const { return static_cast(m_timer.elapsed()); } double time_origin() const; JS::GCPtr timing(); WebIDL::ExceptionOr> mark(String const& mark_name, UserTiming::PerformanceMarkOptions const& mark_options = {}); void clear_marks(Optional mark_name); WebIDL::ExceptionOr>> get_entries() const; WebIDL::ExceptionOr>> get_entries_by_type(String const& type) const; WebIDL::ExceptionOr>> get_entries_by_name(String const& name, Optional type) const; private: explicit Performance(HTML::Window&); virtual JS::ThrowCompletionOr initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::NonnullGCPtr m_window; JS::GCPtr m_timing; Core::ElapsedTimer m_timer; }; }