
With this change, we now have ~1200 CellAllocators across both LibJS and LibWeb in a normal WebContent instance. This gives us a minimum heap size of 4.7 MiB in the scenario where we only have one cell allocated per type. Of course, in practice there will be many more of each type, so the effective overhead is quite a bit smaller than that in practice. I left a few types unconverted to this mechanism because I got tired of doing this. :^)
53 lines
2.2 KiB
C++
53 lines
2.2 KiB
C++
/*
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
* Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibCore/ElapsedTimer.h>
|
|
#include <LibWeb/DOM/EventTarget.h>
|
|
#include <LibWeb/UserTiming/PerformanceMark.h>
|
|
#include <LibWeb/UserTiming/PerformanceMeasure.h>
|
|
|
|
namespace Web::HighResolutionTime {
|
|
|
|
class Performance final : public DOM::EventTarget {
|
|
WEB_PLATFORM_OBJECT(Performance, DOM::EventTarget);
|
|
JS_DECLARE_ALLOCATOR(Performance);
|
|
|
|
public:
|
|
virtual ~Performance() override;
|
|
|
|
double now() const { return static_cast<double>(m_timer.elapsed()); }
|
|
double time_origin() const;
|
|
|
|
JS::GCPtr<NavigationTiming::PerformanceTiming> timing();
|
|
|
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<UserTiming::PerformanceMark>> mark(String const& mark_name, UserTiming::PerformanceMarkOptions const& mark_options = {});
|
|
void clear_marks(Optional<String> mark_name);
|
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<UserTiming::PerformanceMeasure>> measure(String const& measure_name, Variant<String, UserTiming::PerformanceMeasureOptions> const& start_or_measure_options, Optional<String> end_mark);
|
|
void clear_measures(Optional<String> measure_name);
|
|
|
|
WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> get_entries() const;
|
|
WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> get_entries_by_type(String const& type) const;
|
|
WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> get_entries_by_name(String const& name, Optional<String> type) const;
|
|
|
|
private:
|
|
explicit Performance(HTML::Window&);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
WebIDL::ExceptionOr<HighResolutionTime::DOMHighResTimeStamp> convert_name_to_timestamp(JS::Realm& realm, String const& name);
|
|
WebIDL::ExceptionOr<HighResolutionTime::DOMHighResTimeStamp> convert_mark_to_timestamp(JS::Realm& realm, Variant<String, HighResolutionTime::DOMHighResTimeStamp> mark);
|
|
|
|
JS::NonnullGCPtr<HTML::Window> m_window;
|
|
JS::GCPtr<NavigationTiming::PerformanceTiming> m_timing;
|
|
|
|
Core::ElapsedTimer m_timer;
|
|
};
|
|
|
|
}
|