From f4f3622e74eb59adecdaa0c0b0fd0b52b9822016 Mon Sep 17 00:00:00 2001 From: Florian Scholz Date: Tue, 25 Oct 2022 15:59:47 +0200 Subject: [PATCH 1/2] Document PerformanceMark constructor --- files/en-us/web/api/performancemark/index.md | 9 ++- .../performancemark/performancemark/index.md | 72 +++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 files/en-us/web/api/performancemark/performancemark/index.md diff --git a/files/en-us/web/api/performancemark/index.md b/files/en-us/web/api/performancemark/index.md index 798a47dec9b10de..a059ffce77916a3 100644 --- a/files/en-us/web/api/performancemark/index.md +++ b/files/en-us/web/api/performancemark/index.md @@ -13,12 +13,19 @@ browser-compat: api.PerformanceMark {{APIRef("User Timing API")}} -**`PerformanceMark`** is an _abstract_ interface for {{domxref("PerformanceEntry")}} objects with an {{domxref("PerformanceEntry.entryType","entryType")}} of "`mark`". Entries of this type are created by calling {{domxref("Performance.mark","performance.mark()")}} to add a _named_ {{domxref("DOMHighResTimeStamp")}} (the _mark_) to the browser's _performance timeline_. +**`PerformanceMark`** is an _abstract_ interface for {{domxref("PerformanceEntry")}} objects with an {{domxref("PerformanceEntry.entryType","entryType")}} of "`mark`". + +Entries of this type are typically created by calling {{domxref("Performance.mark","performance.mark()")}} to add a _named_ {{domxref("DOMHighResTimeStamp")}} (the _mark_) to the browser's _performance timeline_. To create a performance mark that isn't added to the browser's _performance timeline_, use the constructor. {{InheritanceDiagram}} {{AvailableInWorkers}} +## Constructor + +- {{domxref("PerformanceMark.PerformanceMark", "PerformanceMark()")}} + - : Creates a new `PerformanceMark` object that isn't added to the browser's _performance timeline_. + ## Instance properties This interface has no properties but it extends the following {{domxref("PerformanceEntry")}} properties by qualifying/constraining the properties as follows: diff --git a/files/en-us/web/api/performancemark/performancemark/index.md b/files/en-us/web/api/performancemark/performancemark/index.md new file mode 100644 index 000000000000000..5c2471ff38f8b2a --- /dev/null +++ b/files/en-us/web/api/performancemark/performancemark/index.md @@ -0,0 +1,72 @@ +--- +title: PerformanceMark() +slug: Web/API/PerformanceMark/PerformanceMark +page-type: web-api-constructor +tags: + - API + - Constructor + - Reference + - Web Performance +browser-compat: api.PerformanceMark.PerformanceMark +--- + +{{APIRef("User Timing API")}} + +The **`PerformanceMark()`** constructor creates a {{domxref("DOMHighResTimeStamp","timestamp")}} with the given name. + +Unlike {{domxref("Performance.mark","performance.mark()")}}, performance marks created by the constructor aren't added to the browser's _performance timeline_. This means that calls to the {{domxref("Performance")}} interface's `getEntries*()` methods ({{domxref("Performance.getEntries","getEntries()")}}, {{domxref("Performance.getEntriesByName","getEntriesByName()")}} or {{domxref("Performance.getEntriesByType","getEntriesByType()")}}) won't show entries for these marks. + +## Syntax + +```js-nolint +new PerformanceMark(name) +new PerformanceMark(name, markOptions) +``` + +### Parameters + +- `name` + + - : A string representing the name of the mark. If the + `name` given to this method already exists in the + {{domxref("PerformanceTiming")}} interface, {{jsxref("SyntaxError")}} is + thrown. + +- `markOptions` {{optional_inline}} + + - : An object for specifying a timestamp and additional metadata for the mark. + + - `detail` + - : Arbitrary metadata to include in the mark. + - `startTime` + - : {{domxref("DOMHighResTimeStamp")}} to use as the mark time. + +### Return value + +A {{domxref("PerformanceMark")}} object. + +## Examples + +The following example shows how {{domxref("PerformanceMark")}} entries are constructed and then aren't part of the browser's performance timeline. + +```js +new PerformanceMark("squirrel"); +new PerformanceMark("monkey"); +new PerformanceMark("dog"); + +const allEntries = performance.getEntriesByType("mark"); +console.log(allEntries.length); +// 0 +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("Performance.mark","performance.mark()")}} From ccd87a0b81e384982cc282f920d1d2265b491232 Mon Sep 17 00:00:00 2001 From: Florian Scholz Date: Wed, 26 Oct 2022 13:55:59 +0200 Subject: [PATCH 2/2] addres review comments --- files/en-us/web/api/performance/mark/index.md | 22 ++++++++--------- files/en-us/web/api/performancemark/index.md | 6 ++--- .../performancemark/performancemark/index.md | 24 +++++++++---------- 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/files/en-us/web/api/performance/mark/index.md b/files/en-us/web/api/performance/mark/index.md index 8332b81bc12f4aa..c8df3d0745cddfa 100644 --- a/files/en-us/web/api/performance/mark/index.md +++ b/files/en-us/web/api/performance/mark/index.md @@ -37,25 +37,23 @@ mark(name, markOptions) ### Parameters - `name` - - - : A string representing the name of the mark. If the - `name` given to this method already exists in the - {{domxref("PerformanceTiming")}} interface, {{jsxref("SyntaxError")}} is - thrown. - + - : A string representing the name of the mark. - `markOptions` {{optional_inline}} - - : An object for specifying a timestamp and additional metadata for the mark. - - - `detail` - - : Arbitrary metadata to include in the mark. - - `startTime` - - : {{domxref("DOMHighResTimeStamp")}} to use as the mark time. + - `detail` {{optional_inline}} + - : Arbitrary metadata to include in the mark. Defaults to `null`. + - `startTime` {{optional_inline}} + - : {{domxref("DOMHighResTimeStamp")}} to use as the mark time. Defaults to {{domxref("performance.now()")}}. ### Return value The {{domxref("PerformanceMark")}} entry that was created. +### Exceptions + +- {{jsxref("SyntaxError")}}: Thrown if the `name` given to this method already exists in the {{domxref("PerformanceTiming")}} interface. +- {{jsxref("TypeError")}}: Thrown if `startTime` is negative. + ## Examples The following example shows how to use `mark()` to create and retrieve diff --git a/files/en-us/web/api/performancemark/index.md b/files/en-us/web/api/performancemark/index.md index a059ffce77916a3..c4e10b8d2285717 100644 --- a/files/en-us/web/api/performancemark/index.md +++ b/files/en-us/web/api/performancemark/index.md @@ -13,9 +13,9 @@ browser-compat: api.PerformanceMark {{APIRef("User Timing API")}} -**`PerformanceMark`** is an _abstract_ interface for {{domxref("PerformanceEntry")}} objects with an {{domxref("PerformanceEntry.entryType","entryType")}} of "`mark`". +**`PerformanceMark`** is an interface for {{domxref("PerformanceEntry")}} objects with an {{domxref("PerformanceEntry.entryType","entryType")}} of "`mark`". -Entries of this type are typically created by calling {{domxref("Performance.mark","performance.mark()")}} to add a _named_ {{domxref("DOMHighResTimeStamp")}} (the _mark_) to the browser's _performance timeline_. To create a performance mark that isn't added to the browser's _performance timeline_, use the constructor. +Entries of this type are typically created by calling {{domxref("Performance.mark","performance.mark()")}} to add a _named_ {{domxref("DOMHighResTimeStamp")}} (the _mark_) to the browser's performance timeline. To create a performance mark that isn't added to the browser's performance timeline, use the constructor. {{InheritanceDiagram}} @@ -24,7 +24,7 @@ Entries of this type are typically created by calling {{domxref("Performance.mar ## Constructor - {{domxref("PerformanceMark.PerformanceMark", "PerformanceMark()")}} - - : Creates a new `PerformanceMark` object that isn't added to the browser's _performance timeline_. + - : Creates a new `PerformanceMark` object that isn't added to the browser's performance timeline. ## Instance properties diff --git a/files/en-us/web/api/performancemark/performancemark/index.md b/files/en-us/web/api/performancemark/performancemark/index.md index 5c2471ff38f8b2a..9a25e72a81e5468 100644 --- a/files/en-us/web/api/performancemark/performancemark/index.md +++ b/files/en-us/web/api/performancemark/performancemark/index.md @@ -14,7 +14,7 @@ browser-compat: api.PerformanceMark.PerformanceMark The **`PerformanceMark()`** constructor creates a {{domxref("DOMHighResTimeStamp","timestamp")}} with the given name. -Unlike {{domxref("Performance.mark","performance.mark()")}}, performance marks created by the constructor aren't added to the browser's _performance timeline_. This means that calls to the {{domxref("Performance")}} interface's `getEntries*()` methods ({{domxref("Performance.getEntries","getEntries()")}}, {{domxref("Performance.getEntriesByName","getEntriesByName()")}} or {{domxref("Performance.getEntriesByType","getEntriesByType()")}}) won't show entries for these marks. +Unlike {{domxref("Performance.mark","performance.mark()")}}, performance marks created by the constructor aren't added to the browser's performance timeline. This means that calls to the {{domxref("Performance")}} interface's `getEntries*()` methods ({{domxref("Performance.getEntries","getEntries()")}}, {{domxref("Performance.getEntriesByName","getEntriesByName()")}} or {{domxref("Performance.getEntriesByType","getEntriesByType()")}}) won't show entries for these marks. ## Syntax @@ -26,25 +26,23 @@ new PerformanceMark(name, markOptions) ### Parameters - `name` - - - : A string representing the name of the mark. If the - `name` given to this method already exists in the - {{domxref("PerformanceTiming")}} interface, {{jsxref("SyntaxError")}} is - thrown. - + - : A string representing the name of the mark. - `markOptions` {{optional_inline}} - - : An object for specifying a timestamp and additional metadata for the mark. - - - `detail` - - : Arbitrary metadata to include in the mark. - - `startTime` - - : {{domxref("DOMHighResTimeStamp")}} to use as the mark time. + - `detail` {{optional_inline}} + - : Arbitrary metadata to include in the mark. Defaults to `null`. + - `startTime` {{optional_inline}} + - : {{domxref("DOMHighResTimeStamp")}} to use as the mark time. Defaults to {{domxref("performance.now()")}}. ### Return value A {{domxref("PerformanceMark")}} object. +### Exceptions + +- {{jsxref("SyntaxError")}}: Thrown if the `name` given to this method already exists in the {{domxref("PerformanceTiming")}} interface. +- {{jsxref("TypeError")}}: Thrown if `startTime` is negative. + ## Examples The following example shows how {{domxref("PerformanceMark")}} entries are constructed and then aren't part of the browser's performance timeline.