mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
Merge pull request #895 from lightpanda-io/performance_clear
dummy performance clearMarks and clearMeasures
This commit is contained in:
@@ -29,11 +29,6 @@ pub const Interfaces = .{
|
|||||||
PerformanceMark,
|
PerformanceMark,
|
||||||
};
|
};
|
||||||
|
|
||||||
const MarkOptions = struct {
|
|
||||||
detail: ?Env.JsObject = null,
|
|
||||||
start_time: ?f64 = null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Performance
|
// https://developer.mozilla.org/en-US/docs/Web/API/Performance
|
||||||
pub const Performance = struct {
|
pub const Performance = struct {
|
||||||
pub const prototype = *EventTarget;
|
pub const prototype = *EventTarget;
|
||||||
@@ -66,11 +61,21 @@ pub const Performance = struct {
|
|||||||
return limitedResolutionMs(self.time_origin.read());
|
return limitedResolutionMs(self.time_origin.read());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn _mark(_: *Performance, name: []const u8, _options: ?MarkOptions, page: *Page) !PerformanceMark {
|
pub fn _mark(_: *Performance, name: []const u8, _options: ?PerformanceMark.Options, page: *Page) !PerformanceMark {
|
||||||
const mark: PerformanceMark = try .constructor(name, _options, page);
|
const mark: PerformanceMark = try .constructor(name, _options, page);
|
||||||
// TODO: Should store this in an entries list
|
// TODO: Should store this in an entries list
|
||||||
return mark;
|
return mark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: fn _mark should record the marks in a lookup
|
||||||
|
pub fn _clearMarks(_: *Performance, name: ?[]const u8) void {
|
||||||
|
_ = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: fn _measures should record the marks in a lookup
|
||||||
|
pub fn _clearMeasures(_: *Performance, name: ?[]const u8) void {
|
||||||
|
_ = name;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry
|
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry
|
||||||
@@ -132,17 +137,23 @@ pub const PerformanceMark = struct {
|
|||||||
proto: PerformanceEntry,
|
proto: PerformanceEntry,
|
||||||
detail: ?Env.JsObject,
|
detail: ?Env.JsObject,
|
||||||
|
|
||||||
pub fn constructor(name: []const u8, _options: ?MarkOptions, page: *Page) !PerformanceMark {
|
const Options = struct {
|
||||||
|
detail: ?Env.JsObject = null,
|
||||||
|
start_time: ?f64 = null,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn constructor(name: []const u8, _options: ?Options, page: *Page) !PerformanceMark {
|
||||||
const perf = &page.window.performance;
|
const perf = &page.window.performance;
|
||||||
|
|
||||||
const options = _options orelse MarkOptions{};
|
const options = _options orelse Options{};
|
||||||
const start_time = options.start_time orelse perf._now();
|
const start_time = options.start_time orelse perf._now();
|
||||||
const detail = if (options.detail) |d| try d.persist() else null;
|
|
||||||
|
|
||||||
if (start_time < 0.0) {
|
if (start_time < 0.0) {
|
||||||
return error.TypeError;
|
return error.TypeError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const detail = if (options.detail) |d| try d.persist() else null;
|
||||||
|
|
||||||
const duped_name = try page.arena.dupe(u8, name);
|
const duped_name = try page.arena.dupe(u8, name);
|
||||||
const proto = PerformanceEntry{ .name = duped_name, .entry_type = .mark, .start_time = start_time };
|
const proto = PerformanceEntry{ .name = duped_name, .entry_type = .mark, .start_time = start_time };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user