mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
LibWeb: Introduce Performance Timeline and its Performance functions
This commit is contained in:
parent
4c3f1481ea
commit
31b507afbf
16 changed files with 381 additions and 1 deletions
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/PerformanceTimeline/PerformanceEntry.h>
|
||||
|
||||
namespace Web::PerformanceTimeline {
|
||||
|
||||
// https://www.w3.org/TR/performance-timeline/#dfn-performance-entry-buffer-map
|
||||
struct PerformanceEntryTuple {
|
||||
// https://www.w3.org/TR/performance-timeline/#dfn-performance-entry-buffer
|
||||
// A performance entry buffer to store PerformanceEntry objects, that is initially empty.
|
||||
Vector<JS::Handle<PerformanceEntry>> performance_entry_buffer;
|
||||
|
||||
// https://www.w3.org/TR/performance-timeline/#dfn-maxbuffersize
|
||||
// An integer maxBufferSize, initialized to the registry value for this entry type.
|
||||
// NOTE: The empty state represents Infinite size.
|
||||
Optional<u64> max_buffer_size;
|
||||
|
||||
// https://www.w3.org/TR/performance-timeline/#dfn-availablefromtimeline
|
||||
// A boolean availableFromTimeline, initialized to the registry value for this entry type.
|
||||
AvailableFromTimeline available_from_timeline { AvailableFromTimeline::No };
|
||||
|
||||
// https://www.w3.org/TR/performance-timeline/#dfn-dropped-entries-count
|
||||
// An integer dropped entries count that is initially 0.
|
||||
u64 dropped_entries_count { 0 };
|
||||
|
||||
// https://www.w3.org/TR/performance-timeline/#dfn-determine-if-a-performance-entry-buffer-is-full
|
||||
bool is_full()
|
||||
{
|
||||
// 1. Let num current entries be the size of tuple's performance entry buffer.
|
||||
auto num_current_entries = performance_entry_buffer.size();
|
||||
|
||||
// 2. If num current entries is less than tuples's maxBufferSize, return false.
|
||||
if (!max_buffer_size.has_value() || num_current_entries < max_buffer_size.value())
|
||||
return false;
|
||||
|
||||
// 3. Increase tuple's dropped entries count by 1.
|
||||
++dropped_entries_count;
|
||||
|
||||
// 4. Return true.
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue