-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PerformanceEventTiming API, according to the standard
Summary: Changelog: [Internal] This adds definition of `PerformanceEventTiming` interface, according to the W3C standard, so that [event timing](https://www.w3.org/TR/event-timing) data can be reported from native (the C++ part is in the next diff). See here: https://www.w3.org/TR/event-timing/#performanceeventtiming Reviewed By: christophpurrer Differential Revision: D42279486 fbshipit-source-id: 0dfbcd6e5a08fc1b89651bd35b24fb4e731f8b05
- Loading branch information
1 parent
988a231
commit afd954e
Showing
4 changed files
with
111 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @flow strict | ||
*/ | ||
|
||
export type HighResTimeStamp = number; | ||
export type PerformanceEntryType = 'mark' | 'measure' | 'event' | 'first-input'; | ||
|
||
export class PerformanceEntry { | ||
name: string; | ||
entryType: PerformanceEntryType; | ||
startTime: HighResTimeStamp; | ||
duration: HighResTimeStamp; | ||
|
||
constructor(init: { | ||
name: string, | ||
entryType: PerformanceEntryType, | ||
startTime: HighResTimeStamp, | ||
duration: HighResTimeStamp, | ||
}) { | ||
this.name = init.name; | ||
this.entryType = init.entryType; | ||
this.startTime = init.startTime; | ||
this.duration = init.duration; | ||
} | ||
|
||
toJSON(): { | ||
name: string, | ||
entryType: PerformanceEntryType, | ||
startTime: HighResTimeStamp, | ||
duration: HighResTimeStamp, | ||
} { | ||
return { | ||
name: this.name, | ||
entryType: this.entryType, | ||
startTime: this.startTime, | ||
duration: this.duration, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @flow strict | ||
*/ | ||
|
||
import type {HighResTimeStamp} from './PerformanceEntry'; | ||
|
||
import {PerformanceEntry} from './PerformanceEntry'; | ||
|
||
export class PerformanceEventTiming extends PerformanceEntry { | ||
processingStart: HighResTimeStamp; | ||
processingEnd: HighResTimeStamp; | ||
interactionId: number; | ||
|
||
constructor(init: { | ||
name: string, | ||
startTime?: HighResTimeStamp, | ||
duration?: HighResTimeStamp, | ||
processingStart?: HighResTimeStamp, | ||
processingEnd?: HighResTimeStamp, | ||
interactionId?: number, | ||
isFirstInput?: boolean, | ||
}) { | ||
super({ | ||
name: init.name, | ||
entryType: init.isFirstInput === true ? 'first-input' : 'measure', | ||
startTime: init.startTime ?? 0, | ||
duration: init.duration ?? 0, | ||
}); | ||
this.processingStart = init.processingStart ?? 0; | ||
this.processingEnd = init.processingEnd ?? 0; | ||
this.interactionId = init.interactionId ?? 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters