GeezerVison is showing github.com — perf_hooks: expose webperf global scope interfaces · nodejs/node@587367d
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: doc/api/globals.md +68Lines changed: 68 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -541,6 +541,68 @@ The `MessagePort` class. See [`MessagePort`][] for more details. | 541 | 541 |
| 542 | 542 | This variable may appear to be global but is not. See [`module`][]. | 543 | 543 |
| | 544 | +## `PerformanceEntry` | | 545 | + | | 546 | +<!-- YAML | | 547 | +added: REPLACEME | | 548 | +--> | | 549 | + | | 550 | +<!-- type=global --> | | 551 | + | | 552 | +The `PerformanceEntry` class. See [`PerformanceEntry`][] for more details. | | 553 | + | | 554 | +## `PerformanceMark` | | 555 | + | | 556 | +<!-- YAML | | 557 | +added: REPLACEME | | 558 | +--> | | 559 | + | | 560 | +<!-- type=global --> | | 561 | + | | 562 | +The `PerformanceMark` class. See [`PerformanceMark`][] for more details. | | 563 | + | | 564 | +## `PerformanceMeasure` | | 565 | + | | 566 | +<!-- YAML | | 567 | +added: REPLACEME | | 568 | +--> | | 569 | + | | 570 | +<!-- type=global --> | | 571 | + | | 572 | +The `PerformanceMeasure` class. See [`PerformanceMeasure`][] for more details. | | 573 | + | | 574 | +## `PerformanceObserver` | | 575 | + | | 576 | +<!-- YAML | | 577 | +added: REPLACEME | | 578 | +--> | | 579 | + | | 580 | +<!-- type=global --> | | 581 | + | | 582 | +The `PerformanceObserver` class. See [`PerformanceObserver`][] for more details. | | 583 | + | | 584 | +## `PerformanceObserverEntryList` | | 585 | + | | 586 | +<!-- YAML | | 587 | +added: REPLACEME | | 588 | +--> | | 589 | + | | 590 | +<!-- type=global --> | | 591 | + | | 592 | +The `PerformanceObserverEntryList` class. See | | 593 | +[`PerformanceObserverEntryList`][] for more details. | | 594 | + | | 595 | +## `PerformanceResourceTiming` | | 596 | + | | 597 | +<!-- YAML | | 598 | +added: REPLACEME | | 599 | +--> | | 600 | + | | 601 | +<!-- type=global --> | | 602 | + | | 603 | +The `PerformanceResourceTiming` class. See [`PerformanceResourceTiming`][] for | | 604 | +more details. | | 605 | + | 544 | 606 | ## `performance` | 545 | 607 |
| 546 | 608 | <!-- YAML | @@ -899,6 +961,12 @@ A browser-compatible implementation of [`WritableStreamDefaultWriter`][]. | 899 | 961 | [`MessageChannel`]: worker_threads.md#class-messagechannel | 900 | 962 | [`MessageEvent`]: https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/MessageEvent | 901 | 963 | [`MessagePort`]: worker_threads.md#class-messageport | | 964 | +[`PerformanceEntry`]: perf_hooks.md#class-performanceentry | | 965 | +[`PerformanceMark`]: perf_hooks.md#class-performancemark | | 966 | +[`PerformanceMeasure`]: perf_hooks.md#class-performancemeasure | | 967 | +[`PerformanceObserverEntryList`]: perf_hooks.md#class-performanceobserverentrylist | | 968 | +[`PerformanceObserver`]: perf_hooks.md#class-performanceobserver | | 969 | +[`PerformanceResourceTiming`]: perf_hooks.md#class-performanceresourcetiming | 902 | 970 | [`ReadableByteStreamController`]: webstreams.md#class-readablebytestreamcontroller | 903 | 971 | [`ReadableStreamBYOBReader`]: webstreams.md#class-readablestreambyobreader | 904 | 972 | [`ReadableStreamBYOBRequest`]: webstreams.md#class-readablestreambyobrequest | |
Collapse file Copy file name to clipboardExpand all lines: lib/.eslintrc.yaml +12Lines changed: 12 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -73,6 +73,18 @@ rules: | 73 | 73 | message: Use `const { MessageEvent } = require('internal/worker/io');` instead of the global. | 74 | 74 | - name: MessagePort | 75 | 75 | message: Use `const { MessagePort } = require('internal/worker/io');` instead of the global. | | 76 | + - name: PerformanceEntry | | 77 | + message: Use `const { PerformanceEntry } = require('perf_hooks');` instead of the global. | | 78 | + - name: PerformanceMark | | 79 | + message: Use `const { PerformanceMark } = require('perf_hooks');` instead of the global. | | 80 | + - name: PerformanceMeasure | | 81 | + message: Use `const { PerformanceMeasure } = require('perf_hooks');` instead of the global. | | 82 | + - name: PerformanceObserverEntryList | | 83 | + message: Use `const { PerformanceObserverEntryList } = require('perf_hooks');` instead of the global. | | 84 | + - name: PerformanceObserver | | 85 | + message: Use `const { PerformanceObserver } = require('perf_hooks');` instead of the global. | | 86 | + - name: PerformanceResourceTiming | | 87 | + message: Use `const { PerformanceResourceTiming } = require('perf_hooks');` instead of the global. | 76 | 88 | - name: ReadableStream | 77 | 89 | message: Use `const { ReadableStream } = require('internal/webstreams/readablestream')` instead of the global. | 78 | 90 | - name: ReadableStreamDefaultReader | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/bootstrap/browser.js +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -75,6 +75,12 @@ exposeInterface(globalThis, 'Blob', buffer.Blob); | 75 | 75 | // https://www.w3.org/TR/hr-time-2/#the-performance-attribute | 76 | 76 | const perf_hooks = require('perf_hooks'); | 77 | 77 | exposeInterface(globalThis, 'Performance', perf_hooks.Performance); | | 78 | +exposeInterface(globalThis, 'PerformanceEntry', perf_hooks.PerformanceEntry); | | 79 | +exposeInterface(globalThis, 'PerformanceMark', perf_hooks.PerformanceMark); | | 80 | +exposeInterface(globalThis, 'PerformanceMeasure', perf_hooks.PerformanceMeasure); | | 81 | +exposeInterface(globalThis, 'PerformanceObserver', perf_hooks.PerformanceObserver); | | 82 | +exposeInterface(globalThis, 'PerformanceObserverEntryList', perf_hooks.PerformanceObserverEntryList); | | 83 | +exposeInterface(globalThis, 'PerformanceResourceTiming', perf_hooks.PerformanceResourceTiming); | 78 | 84 | defineReplaceableAttribute(globalThis, 'performance', | 79 | 85 | perf_hooks.performance); | 80 | 86 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/wpt/test-performance-timeline.js -24Lines changed: 0 additions & 24 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -7,30 +7,6 @@ const runner = new WPTRunner('performance-timeline'); | 7 | 7 | runner.pretendGlobalThisAs('Window'); | 8 | 8 | runner.brandCheckGlobalScopeAttribute('performance'); | 9 | 9 | runner.setInitScript(` | 10 | | - const { | 11 | | - PerformanceEntry, | 12 | | - PerformanceObserver, | 13 | | - PerformanceObserverEntryList, | 14 | | - } = require('perf_hooks'); | 15 | | - Object.defineProperty(global, 'PerformanceEntry', { | 16 | | - value: PerformanceEntry, | 17 | | - enumerable: false, | 18 | | - writable: true, | 19 | | - configurable: true, | 20 | | - }); | 21 | | - Object.defineProperty(global, 'PerformanceObserver', { | 22 | | - value: PerformanceObserver, | 23 | | - enumerable: false, | 24 | | - writable: true, | 25 | | - configurable: true, | 26 | | - }); | 27 | | - Object.defineProperty(global, 'PerformanceObserverEntryList', { | 28 | | - value: PerformanceObserverEntryList, | 29 | | - enumerable: false, | 30 | | - writable: true, | 31 | | - configurable: true, | 32 | | - }); | 33 | | -
| 34 | 10 | // Create a dummy resource timing entry to mimic how the browser would | 35 | 11 | // record the initial page load. | 36 | 12 | performance.markResourceTiming({ | |
Collapse file Copy file name to clipboardExpand all lines: test/wpt/test-resource-timing.js -17Lines changed: 0 additions & 17 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -6,23 +6,6 @@ const runner = new WPTRunner('resource-timing'); | 6 | 6 |
| 7 | 7 | runner.pretendGlobalThisAs('Window'); | 8 | 8 | runner.setInitScript(` | 9 | | - const { | 10 | | - PerformanceEntry, | 11 | | - PerformanceResourceTiming, | 12 | | - } = require('perf_hooks'); | 13 | | - Object.defineProperty(global, 'PerformanceEntry', { | 14 | | - value: PerformanceEntry, | 15 | | - enumerable: false, | 16 | | - writable: true, | 17 | | - configurable: true, | 18 | | - }); | 19 | | - Object.defineProperty(global, 'PerformanceResourceTiming', { | 20 | | - value: PerformanceResourceTiming, | 21 | | - enumerable: false, | 22 | | - writable: true, | 23 | | - configurable: true, | 24 | | - }); | 25 | | -
| 26 | 9 | global.resource = performance.markResourceTiming({ | 27 | 10 | startTime: 0, | 28 | 11 | endTime: 0, | |
Collapse file Copy file name to clipboardExpand all lines: test/wpt/test-user-timing.js -32Lines changed: 0 additions & 32 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -7,37 +7,5 @@ const runner = new WPTRunner('user-timing'); | 7 | 7 |
| 8 | 8 | runner.pretendGlobalThisAs('Window'); | 9 | 9 | runner.brandCheckGlobalScopeAttribute('performance'); | 10 | | -runner.setInitScript(` | 11 | | - const { | 12 | | - PerformanceEntry, | 13 | | - PerformanceMark, | 14 | | - PerformanceMeasure, | 15 | | - PerformanceObserver, | 16 | | - } = require('perf_hooks'); | 17 | | - Object.defineProperty(global, 'PerformanceEntry', { | 18 | | - value: PerformanceEntry, | 19 | | - enumerable: false, | 20 | | - writable: true, | 21 | | - configurable: true, | 22 | | - }); | 23 | | - Object.defineProperty(global, 'PerformanceMark', { | 24 | | - value: PerformanceMark, | 25 | | - enumerable: false, | 26 | | - writable: true, | 27 | | - configurable: true, | 28 | | - }); | 29 | | - Object.defineProperty(global, 'PerformanceMeasure', { | 30 | | - value: PerformanceMeasure, | 31 | | - enumerable: false, | 32 | | - writable: true, | 33 | | - configurable: true, | 34 | | - }); | 35 | | - Object.defineProperty(global, 'PerformanceObserver', { | 36 | | - value: PerformanceObserver, | 37 | | - enumerable: false, | 38 | | - writable: true, | 39 | | - configurable: true, | 40 | | - }); | 41 | | -`); | 42 | 10 |
| 43 | 11 | runner.runJsTests(); |
|