Skip to content

Commit

Permalink
Implement User Timing Level 3
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulWagener committed Dec 4, 2023
1 parent cfe3dc2 commit 50a8208
Show file tree
Hide file tree
Showing 12 changed files with 282 additions and 20 deletions.
2 changes: 2 additions & 0 deletions crates/web-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,9 @@ PerformanceEntry = []
PerformanceEntryEventInit = []
PerformanceEntryFilterOptions = []
PerformanceMark = ["PerformanceEntry"]
PerformanceMarkOptions = []
PerformanceMeasure = ["PerformanceEntry"]
PerformanceMeasureOptions = []
PerformanceNavigation = []
PerformanceNavigationTiming = ["PerformanceEntry", "PerformanceResourceTiming"]
PerformanceObserver = []
Expand Down
65 changes: 53 additions & 12 deletions crates/web-sys/src/features/gen_Performance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,43 +116,84 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Performance`*"]
pub fn get_entries_by_type(this: &Performance, entry_type: &str) -> ::js_sys::Array;
#[cfg(feature = "PerformanceMark")]
# [wasm_bindgen (catch , method , structural , js_class = "Performance" , js_name = mark)]
#[doc = "The `mark()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Performance`*"]
pub fn mark(this: &Performance, mark_name: &str) -> Result<(), JsValue>;
#[doc = "*This API requires the following crate features to be activated: `Performance`, `PerformanceMark`*"]
pub fn mark(this: &Performance, mark_name: &str) -> Result<PerformanceMark, JsValue>;
#[cfg(all(feature = "PerformanceMark", feature = "PerformanceMarkOptions",))]
# [wasm_bindgen (catch , method , structural , js_class = "Performance" , js_name = mark)]
#[doc = "The `mark()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Performance`, `PerformanceMark`, `PerformanceMarkOptions`*"]
pub fn mark_with_mark_options(
this: &Performance,
mark_name: &str,
mark_options: &PerformanceMarkOptions,
) -> Result<PerformanceMark, JsValue>;
#[cfg(feature = "PerformanceMeasure")]
# [wasm_bindgen (catch , method , structural , js_class = "Performance" , js_name = measure)]
#[doc = "The `measure()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Performance`*"]
pub fn measure(this: &Performance, measure_name: &str) -> Result<(), JsValue>;
#[doc = "*This API requires the following crate features to be activated: `Performance`, `PerformanceMeasure`*"]
pub fn measure(this: &Performance, measure_name: &str) -> Result<PerformanceMeasure, JsValue>;
#[cfg(feature = "PerformanceMeasure")]
# [wasm_bindgen (catch , method , structural , js_class = "Performance" , js_name = measure)]
#[doc = "The `measure()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Performance`*"]
pub fn measure_with_start_mark(
#[doc = "*This API requires the following crate features to be activated: `Performance`, `PerformanceMeasure`*"]
pub fn measure_with_str(
this: &Performance,
measure_name: &str,
start_mark: &str,
) -> Result<(), JsValue>;
start_or_measure_options: &str,
) -> Result<PerformanceMeasure, JsValue>;
#[cfg(all(feature = "PerformanceMeasure", feature = "PerformanceMeasureOptions",))]
# [wasm_bindgen (catch , method , structural , js_class = "Performance" , js_name = measure)]
#[doc = "The `measure()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Performance`*"]
pub fn measure_with_start_mark_and_end_mark(
#[doc = "*This API requires the following crate features to be activated: `Performance`, `PerformanceMeasure`, `PerformanceMeasureOptions`*"]
pub fn measure_with_performance_measure_options(
this: &Performance,
measure_name: &str,
start_or_measure_options: &PerformanceMeasureOptions,
) -> Result<PerformanceMeasure, JsValue>;
#[cfg(feature = "PerformanceMeasure")]
# [wasm_bindgen (catch , method , structural , js_class = "Performance" , js_name = measure)]
#[doc = "The `measure()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Performance`, `PerformanceMeasure`*"]
pub fn measure_with_str_and_end_mark(
this: &Performance,
measure_name: &str,
start_or_measure_options: &str,
end_mark: &str,
) -> Result<PerformanceMeasure, JsValue>;
#[cfg(all(feature = "PerformanceMeasure", feature = "PerformanceMeasureOptions",))]
# [wasm_bindgen (catch , method , structural , js_class = "Performance" , js_name = measure)]
#[doc = "The `measure()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Performance`, `PerformanceMeasure`, `PerformanceMeasureOptions`*"]
pub fn measure_with_performance_measure_options_and_end_mark(
this: &Performance,
measure_name: &str,
start_mark: &str,
start_or_measure_options: &PerformanceMeasureOptions,
end_mark: &str,
) -> Result<(), JsValue>;
) -> Result<PerformanceMeasure, JsValue>;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "Performance" , js_name = measureUserAgentSpecificMemory)]
#[doc = "The `measureUserAgentSpecificMemory()` method."]
Expand Down
25 changes: 25 additions & 0 deletions crates/web-sys/src/features/gen_PerformanceMark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,29 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `PerformanceMark`*"]
pub type PerformanceMark;
# [wasm_bindgen (structural , method , getter , js_class = "PerformanceMark" , js_name = detail)]
#[doc = "Getter for the `detail` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceMark/detail)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `PerformanceMark`*"]
pub fn detail(this: &PerformanceMark) -> ::wasm_bindgen::JsValue;
#[wasm_bindgen(catch, constructor, js_class = "PerformanceMark")]
#[doc = "The `new PerformanceMark(..)` constructor, creating a new instance of `PerformanceMark`."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceMark/PerformanceMark)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `PerformanceMark`*"]
pub fn new(mark_name: &str) -> Result<PerformanceMark, JsValue>;
#[cfg(feature = "PerformanceMarkOptions")]
#[wasm_bindgen(catch, constructor, js_class = "PerformanceMark")]
#[doc = "The `new PerformanceMark(..)` constructor, creating a new instance of `PerformanceMark`."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceMark/PerformanceMark)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `PerformanceMark`, `PerformanceMarkOptions`*"]
pub fn new_with_mark_options(
mark_name: &str,
mark_options: &PerformanceMarkOptions,
) -> Result<PerformanceMark, JsValue>;
}
59 changes: 59 additions & 0 deletions crates/web-sys/src/features/gen_PerformanceMarkOptions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = PerformanceMarkOptions)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `PerformanceMarkOptions` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `PerformanceMarkOptions`*"]
pub type PerformanceMarkOptions;
}
impl PerformanceMarkOptions {
#[doc = "Construct a new `PerformanceMarkOptions`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `PerformanceMarkOptions`*"]
pub fn new() -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[doc = "Change the `detail` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `PerformanceMarkOptions`*"]
pub fn detail(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
use wasm_bindgen::JsValue;
let r =
::js_sys::Reflect::set(self.as_ref(), &JsValue::from("detail"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `startTime` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `PerformanceMarkOptions`*"]
pub fn start_time(&mut self, val: f64) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("startTime"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
}
impl Default for PerformanceMarkOptions {
fn default() -> Self {
Self::new()
}
}
7 changes: 7 additions & 0 deletions crates/web-sys/src/features/gen_PerformanceMeasure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `PerformanceMeasure`*"]
pub type PerformanceMeasure;
# [wasm_bindgen (structural , method , getter , js_class = "PerformanceMeasure" , js_name = detail)]
#[doc = "Getter for the `detail` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceMeasure/detail)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `PerformanceMeasure`*"]
pub fn detail(this: &PerformanceMeasure) -> ::wasm_bindgen::JsValue;
}
85 changes: 85 additions & 0 deletions crates/web-sys/src/features/gen_PerformanceMeasureOptions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = PerformanceMeasureOptions)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `PerformanceMeasureOptions` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `PerformanceMeasureOptions`*"]
pub type PerformanceMeasureOptions;
}
impl PerformanceMeasureOptions {
#[doc = "Construct a new `PerformanceMeasureOptions`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `PerformanceMeasureOptions`*"]
pub fn new() -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[doc = "Change the `detail` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `PerformanceMeasureOptions`*"]
pub fn detail(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
use wasm_bindgen::JsValue;
let r =
::js_sys::Reflect::set(self.as_ref(), &JsValue::from("detail"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `duration` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `PerformanceMeasureOptions`*"]
pub fn duration(&mut self, val: f64) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("duration"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `end` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `PerformanceMeasureOptions`*"]
pub fn end(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("end"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `start` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `PerformanceMeasureOptions`*"]
pub fn start(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("start"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
}
impl Default for PerformanceMeasureOptions {
fn default() -> Self {
Self::new()
}
}
12 changes: 12 additions & 0 deletions crates/web-sys/src/features/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5380,12 +5380,24 @@ mod gen_PerformanceMark;
#[cfg(feature = "PerformanceMark")]
pub use gen_PerformanceMark::*;

#[cfg(feature = "PerformanceMarkOptions")]
#[allow(non_snake_case)]
mod gen_PerformanceMarkOptions;
#[cfg(feature = "PerformanceMarkOptions")]
pub use gen_PerformanceMarkOptions::*;

#[cfg(feature = "PerformanceMeasure")]
#[allow(non_snake_case)]
mod gen_PerformanceMeasure;
#[cfg(feature = "PerformanceMeasure")]
pub use gen_PerformanceMeasure::*;

#[cfg(feature = "PerformanceMeasureOptions")]
#[allow(non_snake_case)]
mod gen_PerformanceMeasureOptions;
#[cfg(feature = "PerformanceMeasureOptions")]
pub use gen_PerformanceMeasureOptions::*;

#[cfg(feature = "PerformanceNavigation")]
#[allow(non_snake_case)]
mod gen_PerformanceNavigation;
Expand Down
8 changes: 4 additions & 4 deletions crates/web-sys/webidls/enabled/Performance.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ partial interface Performance {
attribute EventHandler onresourcetimingbufferfull;
};

// http://www.w3.org/TR/user-timing/
// https://www.w3.org/TR/user-timing/#extensions-performance-interface
[Exposed=(Window,Worker)]
partial interface Performance {
[Throws]
undefined mark(DOMString markName);
PerformanceMark mark(DOMString markName, optional PerformanceMarkOptions markOptions = {});
undefined clearMarks(optional DOMString markName);
[Throws]
undefined measure(DOMString measureName, optional DOMString startMark, optional DOMString endMark);
PerformanceMeasure measure(DOMString measureName, optional (DOMString or PerformanceMeasureOptions) startOrMeasureOptions = {}, optional DOMString endMark);
undefined clearMeasures(optional DOMString measureName);
};
};
5 changes: 3 additions & 2 deletions crates/web-sys/webidls/enabled/PerformanceMark.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

[Exposed=(Window,Worker)]
interface PerformanceMark : PerformanceEntry
{
interface PerformanceMark : PerformanceEntry {
constructor(DOMString markName, optional PerformanceMarkOptions markOptions = {});
readonly attribute any detail;
};
14 changes: 14 additions & 0 deletions crates/web-sys/webidls/enabled/PerformanceMarkOptions.webidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* https://www.w3.org/TR/user-timing/#extensions-performance-interface
*/

[Exposed=(Window,Worker)]
dictionary PerformanceMarkOptions {
any detail;
DOMHighResTimeStamp startTime;
};
4 changes: 2 additions & 2 deletions crates/web-sys/webidls/enabled/PerformanceMeasure.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
*/

[Exposed=(Window,Worker)]
interface PerformanceMeasure : PerformanceEntry
{
interface PerformanceMeasure : PerformanceEntry {
readonly attribute any detail;
};
16 changes: 16 additions & 0 deletions crates/web-sys/webidls/enabled/PerformanceMeasureOptions.webidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* https://www.w3.org/TR/user-timing/#extensions-performance-interface
*/

[Exposed=(Window,Worker)]
dictionary PerformanceMeasureOptions {
any detail;
(DOMString or DOMHighResTimeStamp) start;
DOMHighResTimeStamp duration;
(DOMString or DOMHighResTimeStamp) end;
};

0 comments on commit 50a8208

Please sign in to comment.