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
Changes from 1 commit
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
Next Next commit
move
skyclouds2001 committed Apr 29, 2024
commit dfb8c72c3e775b4a763ad5c495756e2897a46847
9 changes: 4 additions & 5 deletions files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
@@ -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
@@ -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
@@ -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
@@ -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
@@ -10706,6 +10704,7 @@
/en-US/docs/Web/API/notification_1/vibrate /en-US/docs/Web/API/Notification/vibrate
/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/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
@@ -10887,7 +10886,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
40 changes: 20 additions & 20 deletions files/en-us/_wikihistory.json
Original file line number Diff line number Diff line change
@@ -67949,6 +67949,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": [
@@ -71578,26 +71598,6 @@
"ziyunfei"
]
},
"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": [
2 changes: 1 addition & 1 deletion files/en-us/web/api/performance/index.md
Original file line number Diff line number Diff line change
@@ -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.
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 {{domxref("window.performance")}} for which APIs are available in window and worker contexts.

{{InheritanceDiagram}}

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
@@ -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 for each global using {{domxref("Window.performance")}} or {{domxref("WorkerGlobalScope.performance")}} 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.

@@ -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")}}
Original file line number Diff line number Diff line change
@@ -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.
The Performance API collects performance data for each global object (`window.performance` or `self.performance` in workers). See {{domxref("window.performance")}} for which APIs are available in window and worker contexts. If you are collecting performance metrics for multiple contexts, also take a look at {{domxref("performance.timeOrigin")}} to synchronize time origins between contexts.

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

2 changes: 1 addition & 1 deletion files/en-us/web/api/window/index.md
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
title: performance global property
title: "Window: performance property"
short-title: performance
slug: Web/API/performance_property
page-type: web-api-global-property
slug: Web/API/Window/performance
page-type: web-api-instance-property
browser-compat: api.performance
---

{{APIRef("Performance API")}}{{AvailableInWorkers}}
{{APIRef("Performance API")}}

The global **`performance`** property returns a {{domxref("Performance")}} object, which can be used to gather performance information about the context it is called in (window or worker).
The **`performance`** property of the {{domxref("Window")}} interface returns a {{domxref("Performance")}} object, which can be used to gather performance information about the context it is called in window.

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 for the context it is called on (window or worker).
A {{domxref("Performance")}} object offering access to performance and timing-related information for the context it is called on window.

## Performance API availability

@@ -50,3 +50,7 @@ The following table provides an overview about the availability of the performan
## Browser compatibility

{{Compat}}

## See also

- {{domxref("WorkerGlobalScope.performance")}}
2 changes: 1 addition & 1 deletion files/en-us/web/api/workerglobalscope/index.md
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ _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("origin", "WorkerGlobalScope.origin")}} {{ReadOnlyInline}}
- : Returns the global object's origin, serialized as a string.
- {{domxref("performance_property", "WorkerGlobalScope.performance")}} {{ReadOnlyInline}}
- {{domxref("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("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).
33 changes: 33 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,33 @@
---
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 the context it is called in worker.

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 for the context it is called on worker.

## Performance API availability

See the table which provides an overview about the availability of the performance APIs in window and worker contexts at {{domxref("Window.performance")}}.

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("Window.performance")}}
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion files/jsondata/GroupData.json
Original file line number Diff line number Diff line change
@@ -1108,7 +1108,7 @@
"VisibilityStateEntry"
],
"methods": [],
"properties": ["performance_property"],
"properties": ["Window.performance", "WorkerGlobalScope.performance"],
"events": []
},
"Periodic Background Sync": {
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -60,5 +60,6 @@
},
"devDependencies": {
"jest": "^29.7.0"
}
},
"packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
}