Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix globals, part 6: performance #33339

Merged
merged 9 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2196,7 +2196,7 @@
/en-US/docs/DOM/window.outerHeight /en-US/docs/Web/API/Window/outerHeight
/en-US/docs/DOM/window.outerWidth /en-US/docs/Web/API/Window/outerWidth
/en-US/docs/DOM/window.parent /en-US/docs/Web/API/Window/parent
/en-US/docs/DOM/window.performance /en-US/docs/Web/API/performance_property
/en-US/docs/DOM/window.performance /en-US/docs/Web/API/Window/performance
/en-US/docs/DOM/window.performance.now /en-US/docs/Web/API/Performance/now
/en-US/docs/DOM/window.personalbar /en-US/docs/Web/API/Window/personalbar
/en-US/docs/DOM/window.postMessage /en-US/docs/Web/API/Window/postMessage
Expand Down Expand Up @@ -10210,7 +10210,6 @@
/en-US/docs/Web/API/Window/openDialog /en-US/docs/Web/API/Window
/en-US/docs/Web/API/Window/pageXOffset /en-US/docs/Web/API/Window/scrollX
/en-US/docs/Web/API/Window/pageYOffset /en-US/docs/Web/API/Window/scrollY
/en-US/docs/Web/API/Window/performance /en-US/docs/Web/API/performance_property
/en-US/docs/Web/API/Window/removeEventListener /en-US/docs/Web/API/EventTarget/removeEventListener
/en-US/docs/Web/API/Window/resolveLocalFileSystemURL /en-US/docs/Web/API/File_and_Directory_Entries_API#resolvelocalfilesystemurl()
/en-US/docs/Web/API/Window/restore /en-US/docs/Web/API/Window/moveTo
Expand Down Expand Up @@ -10303,7 +10302,7 @@
/en-US/docs/Web/API/WorkerGlobalScope.onlanguagechange /en-US/docs/Web/API/WorkerGlobalScope/languagechange_event
/en-US/docs/Web/API/WorkerGlobalScope.onoffline /en-US/docs/Web/API/WorkerGlobalScope/offline_event
/en-US/docs/Web/API/WorkerGlobalScope.ononline /en-US/docs/Web/API/WorkerGlobalScope/online_event
/en-US/docs/Web/API/WorkerGlobalScope.performance /en-US/docs/Web/API/performance_property
/en-US/docs/Web/API/WorkerGlobalScope.performance /en-US/docs/Web/API/WorkerGlobalScope/performance
/en-US/docs/Web/API/WorkerGlobalScope.self /en-US/docs/Web/API/WorkerGlobalScope/self
/en-US/docs/Web/API/WorkerGlobalScope/WorkerGlobalScope.caches /en-US/docs/Web/API/caches
/en-US/docs/Web/API/WorkerGlobalScope/atob /en-US/docs/Web/API/atob
Expand All @@ -10319,7 +10318,6 @@
/en-US/docs/Web/API/WorkerGlobalScope/onlanguagechange /en-US/docs/Web/API/WorkerGlobalScope/languagechange_event
/en-US/docs/Web/API/WorkerGlobalScope/onoffline /en-US/docs/Web/API/WorkerGlobalScope/offline_event
/en-US/docs/Web/API/WorkerGlobalScope/ononline /en-US/docs/Web/API/WorkerGlobalScope/online_event
/en-US/docs/Web/API/WorkerGlobalScope/performance /en-US/docs/Web/API/performance_property
/en-US/docs/Web/API/WorkerGlobalScope/requestFileSystemSync /en-US/docs/Web/API/File_and_Directory_Entries_API
/en-US/docs/Web/API/WorkerGlobalScope/setInterval /en-US/docs/Web/API/setInterval
/en-US/docs/Web/API/WorkerGlobalScope/setTimeout /en-US/docs/Web/API/setTimeout
Expand Down Expand Up @@ -10707,6 +10705,7 @@
/en-US/docs/Web/API/onMSVideoOptimalLayoutChanged /en-US/docs/Web/API/HTMLVideoElement
/en-US/docs/Web/API/onMSVideoOptimalLayoutChanged_ /en-US/docs/Web/API/HTMLVideoElement
/en-US/docs/Web/API/origin /en-US/docs/Web/API/Window/origin
/en-US/docs/Web/API/performance_property /en-US/docs/Web/API/Window/performance
/en-US/docs/Web/API/range.cloneContents /en-US/docs/Web/API/range/cloneContents
/en-US/docs/Web/API/range.cloneRange /en-US/docs/Web/API/range/cloneRange
/en-US/docs/Web/API/range.collapse /en-US/docs/Web/API/range/collapse
Expand Down Expand Up @@ -10888,7 +10887,7 @@
/en-US/docs/Web/API/window.outerHeight /en-US/docs/Web/API/Window/outerHeight
/en-US/docs/Web/API/window.outerWidth /en-US/docs/Web/API/Window/outerWidth
/en-US/docs/Web/API/window.parent /en-US/docs/Web/API/Window/parent
/en-US/docs/Web/API/window.performance /en-US/docs/Web/API/performance_property
/en-US/docs/Web/API/window.performance /en-US/docs/Web/API/Window/performance
/en-US/docs/Web/API/window.performance.now /en-US/docs/Web/API/Performance/now
/en-US/docs/Web/API/window.personalbar /en-US/docs/Web/API/Window/personalbar
/en-US/docs/Web/API/window.postMessage /en-US/docs/Web/API/Window/postMessage
Expand Down
40 changes: 20 additions & 20 deletions files/en-us/_wikihistory.json
Original file line number Diff line number Diff line change
Expand Up @@ -67960,6 +67960,26 @@
"modified": "2020-10-15T22:16:14.230Z",
"contributors": ["mfuji09", "wbamberg"]
},
"Web/API/Window/performance": {
"modified": "2020-10-15T21:22:10.802Z",
"contributors": [
"sideshowbarker",
"connorshea",
"Sheppy",
"anonyco",
"kmag",
"sarafec",
"smarts",
"jsantell",
"fscholz",
"paul.irish",
"teoli",
"julienw",
"iamanupmenon",
"ethertank",
"MattBrubeck"
]
},
"Web/API/Window/personalbar": {
"modified": "2020-10-15T21:14:01.101Z",
"contributors": [
Expand Down Expand Up @@ -71578,26 +71598,6 @@
"kscarfone"
]
},
"Web/API/performance_property": {
"modified": "2020-10-15T21:22:10.802Z",
"contributors": [
"sideshowbarker",
"connorshea",
"Sheppy",
"anonyco",
"kmag",
"sarafec",
"smarts",
"jsantell",
"fscholz",
"paul.irish",
"teoli",
"julienw",
"iamanupmenon",
"ethertank",
"MattBrubeck"
]
},
"Web/API/queueMicrotask": {
"modified": "2020-10-15T22:21:06.789Z",
"contributors": [
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/performance/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ browser-compat: api.Performance

The **`Performance`** interface provides access to performance-related information for the current page.

An object of this type can be obtained by calling `window.performance` or `self.performance` in workers. Note that Performance entries are per context. If you create a mark on the main thread (or other worker), you cannot see it in a worker thread, and vice versa. See [`self.performance`](/en-US/docs/Web/API/performance_property) for which APIs are available in window and worker contexts.
Performance entries are specific to each execution context. You can access performance information for code running in a window via {{domxref("Window.performance")}}, and for code running in a worker via {{domxref("WorkerGlobalScope.performance")}}.

{{InheritanceDiagram}}

Expand Down
4 changes: 2 additions & 2 deletions files/en-us/web/api/performance_api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Each performance metric is represented by a single {{domxref("PerformanceEntry")

Most of the performance entries are recorded for you without you having to do anything, and are then accessible either through {{domxref("Performance.getEntries()")}} or (preferably) through {{domxref("PerformanceObserver")}}. For example, {{domxref("PerformanceEventTiming")}} entries are recorded for events that take longer than a set threshold. But the Performance API also enables you to define and record your own custom events, using the {{domxref("PerformanceMark")}} and {{domxref("PerformanceMeasure")}} interfaces.

The main {{domxref("Performance")}} interface is available for each global using {{domxref("performance_property", "self.performance")}} and enables you to add custom performance entries, to clear performance entries, and to retrieve performance entries.
The main {{domxref("Performance")}} interface is available in both {{domxref("Window.performance", "Window")}} and {{domxref("WorkerGlobalScope.performance", "Worker")}} global scopes, and enables you to add custom performance entries, to clear performance entries, and to retrieve performance entries.

The {{domxref("PerformanceObserver")}} interface enables you to listen for various types of performance entry as they are recorded.

Expand All @@ -50,7 +50,7 @@ The following interfaces are present in the Performance API:
- {{domxref("LayoutShiftAttribution")}}
- : Provides debugging information about elements which have shifted.
- {{domxref("Performance")}}
- : Main interface to access performance measurements. Available to window and worker contexts using {{domxref("performance_property", "self.performance")}}.
- : Main interface to access performance measurements. Available to window and worker contexts using {{domxref("Window.performance")}} or {{domxref("WorkerGlobalScope.performance")}}.
- {{domxref("PerformanceElementTiming")}}
- : Measures rendering timestamps of specific elements.
- {{domxref("PerformanceEntry")}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ For some metrics you do have to tell the browser what to measure:

## Performance data structure

The Performance API collects performance data for each global object (`window.performance` or `self.performance` in workers). See [`self.performance`](/en-US/docs/Web/API/performance_property) for which APIs are available in window and worker contexts. If you are collecting performance metrics for multiple contexts, also take a look at [`performance.timeOrigin`](/en-US/docs/Web/API/Performance/timeOrigin) to synchronize time origins between contexts.
With the Performance API you can collect performance data in both {{domxref("Window.performance", "Window")}} and {{domxref("WorkerGlobalScope.performance", "Worker")}} global contexts. If you are collecting performance metrics for multiple contexts, take a look at {{domxref("performance.timeOrigin")}} to synchronize time origins between contexts.

Within these contexts, individual performance data is represented by performance entries.

Expand Down
52 changes: 0 additions & 52 deletions files/en-us/web/api/performance_property/index.md

This file was deleted.

2 changes: 1 addition & 1 deletion files/en-us/web/api/window/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Note that properties which are objects (e.g., for overriding the prototype of bu
- : An alias for {{domxref("window.scrollY")}}.
- {{domxref("Window.parent")}} {{ReadOnlyInline}}
- : Returns a reference to the parent of the current window or subframe.
- {{domxref("performance_property", "Window.performance")}} {{ReadOnlyInline}}
- {{domxref("Window.performance")}} {{ReadOnlyInline}}
- : Returns a {{domxref("Performance")}} object, which includes the {{domxref("Performance.timing", "timing")}} and {{domxref("Performance.navigation", "navigation")}} attributes, each of which is an object providing [performance-related](/en-US/docs/Web/API/Performance_API/Navigation_timing) data. See also [Using Navigation Timing](/en-US/docs/Web/API/Performance_API/Navigation_timing) for additional information and examples.
- {{domxref("Window.personalbar")}} {{ReadOnlyInline}}
- : Returns the personalbar object.
Expand Down
29 changes: 29 additions & 0 deletions files/en-us/web/api/window/performance/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: "Window: performance property"
short-title: performance
slug: Web/API/Window/performance
page-type: web-api-instance-property
browser-compat: api.performance
---

{{APIRef("Performance API")}}

The **`performance`** property of the {{domxref("Window")}} interface returns a {{domxref("Performance")}} object, which can be used to gather performance information about code running in the window's scope.

Performance entries are per context. If you create a mark on the main thread (or other worker), you cannot see it in a worker thread, and vice versa.

## Value

A {{domxref("Performance")}} object offering access to performance and timing-related information about code running in the window's scope.

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("WorkerGlobalScope.performance")}}
4 changes: 2 additions & 2 deletions files/en-us/web/api/workerglobalscope/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ _This interface inherits properties from the {{domxref("EventTarget")}} interfac
- : Returns the {{domxref("WorkerNavigator")}} associated with the worker. It is a specific navigator object, mostly a subset of the {{domxref("Navigator")}} for browsing scopes, but adapted to workers.
- {{domxref("WorkerGlobalScope.origin")}} {{ReadOnlyInline}}
- : Returns the global object's origin, serialized as a string.
- {{domxref("performance_property", "WorkerGlobalScope.performance")}} {{ReadOnlyInline}}
- : Returns the {{domxref("Performance")}} associated with the worker. It is a regular performance object, except that only a subset of its property and methods are available to workers.
- {{domxref("WorkerGlobalScope.performance")}} {{ReadOnlyInline}}
- : Returns the {{domxref("Performance")}} associated with the worker. Only a subset of the properties and methods of the `Performance` interface are available to workers.
wbamberg marked this conversation as resolved.
Show resolved Hide resolved
- {{domxref("scheduler_property", "WorkerGlobalScope.scheduler")}} {{ReadOnlyInline}}
- : Returns the {{domxref("Scheduler")}} object associated with the current context. This is the entry point for using the [Prioritized Task Scheduling API](/en-US/docs/Web/API/Prioritized_Task_Scheduling_API).
- {{domxref("WorkerGlobalScope.self")}} {{ReadOnlyInline}}
Expand Down
40 changes: 40 additions & 0 deletions files/en-us/web/api/workerglobalscope/performance/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: "WorkerGlobalScope: performance property"
short-title: performance
slug: Web/API/WorkerGlobalScope/performance
page-type: web-api-instance-property
browser-compat: api.performance
---

{{APIRef("Performance API")}}

The **`performance`** property of the {{domxref("WorkerGlobalScope")}} interface returns a {{domxref("Performance")}} object, which can be used to gather performance information about code running in the worker's scope.

Performance entries are per context. If you create a mark on a worker thread, you will not see it in the main thread or any other workers.

Note that only the following performance interfaces are available in worker contexts:

- {{domxref("Performance")}}
- {{domxref("PerformanceEntry")}}
- {{domxref("PerformanceMark")}}
- {{domxref("PerformanceMeasure")}}
- {{domxref("PerformanceObserver")}}
- {{domxref("PerformanceObserverEntryList")}}
- {{domxref("PerformanceResourceTiming")}}
- {{domxref("PerformanceServerTiming")}}

## Value

A {{domxref("Performance")}} object offering access to performance and timing-related information for the context it is called on worker.
wbamberg marked this conversation as resolved.
Show resolved Hide resolved

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("Window.performance")}}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ end = new Date();
console.log(`Operation took ${end.getTime() - start.getTime()} msec`);
```

> **Note:** In browsers that support the {{domxref("performance_property", "Web Performance API", "", 1)}}'s high-resolution time feature, {{domxref("Performance.now()")}} can provide more reliable and precise measurements of elapsed time than {{jsxref("Date.now()")}}.
> **Note:** In browsers that support the {{domxref("Performance API", "", "", "nocode")}}'s high-resolution time feature, {{domxref("Performance.now()")}} can provide more reliable and precise measurements of elapsed time than {{jsxref("Date.now()")}}.

## Specifications

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ function printElapsedTime(testFn) {
const yourFunctionReturn = printElapsedTime(yourFunction);
```

> **Note:** In browsers that support the {{domxref("performance_property", "Web Performance API", "", 1)}}'s high-resolution time feature, {{domxref("Performance.now()")}} can provide more reliable and precise measurements of elapsed time than {{jsxref("Date.now()")}}.
> **Note:** In browsers that support the {{domxref("Performance API", "", "", "nocode")}}'s high-resolution time feature, {{domxref("Performance.now()")}} can provide more reliable and precise measurements of elapsed time than {{jsxref("Date.now()")}}.

### Get the number of seconds since the ECMAScript Epoch

Expand Down
2 changes: 1 addition & 1 deletion files/jsondata/GroupData.json
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@
"VisibilityStateEntry"
],
"methods": [],
"properties": ["performance_property"],
"properties": ["Window.performance", "WorkerGlobalScope.performance"],
"events": []
},
"Periodic Background Sync": {
Expand Down
Loading