mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
09ad0cc0c6
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/35768 Changelog: [Internal] This implements native side mechanics for reporting user events timing to JS (PerformanceObserver API). See the standard for more details: https://www.w3.org/TR/event-timing/ The events are only logged when there are any active subscriptions (via `PerformanceObserver.observe`), also we only log "discrete events" (i.e. no likes of mouse move), so the overhead is non-existing. There are two main metrics of interest for an event lifecycle: * Time the event is spent in the queue, i.e. the time between it's created and dispatched * Time that is spend in the event handler on the JS side (event dispatch), or processing time Both of these are measured, and the corresponding fields are populated. Reviewed By: sammy-SC Differential Revision: D42294947 fbshipit-source-id: 4fd7938c04b942400befa4057d4929fb2763cee1
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
/**
|
|
* 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' : 'event',
|
|
startTime: init.startTime ?? 0,
|
|
duration: init.duration ?? 0,
|
|
});
|
|
this.processingStart = init.processingStart ?? 0;
|
|
this.processingEnd = init.processingEnd ?? 0;
|
|
this.interactionId = init.interactionId ?? 0;
|
|
}
|
|
}
|