mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/54214 # Changelog: [Internal] React started using `clearMeasures` in https://github.com/facebook/react/pull/34803. It only does it if `performance.measure()` is defined. This should be enough for a feature check of User Timings API presence, but out stub doesn't follow the same spec. Adding `clearMarks()` and `clearMeasures()` stubs to the object. Reviewed By: rubennorte Differential Revision: D85082720 fbshipit-source-id: 3b117a6545e131cdbb2d5efb73d500a928469864
33 lines
993 B
JavaScript
33 lines
993 B
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.
|
|
*
|
|
* @flow strict-local
|
|
* @format
|
|
*/
|
|
|
|
import setUpPerformanceModern from '../../src/private/setup/setUpPerformanceModern';
|
|
import NativePerformance from '../../src/private/webapis/performance/specs/NativePerformance';
|
|
|
|
// In case if the native implementation of the Performance API is available, use it,
|
|
// otherwise fall back to the legacy/default one, which only defines 'Performance.now()'
|
|
if (NativePerformance) {
|
|
setUpPerformanceModern();
|
|
} else {
|
|
if (!global.performance) {
|
|
// $FlowExpectedError[cannot-write]
|
|
global.performance = {
|
|
mark: () => {},
|
|
clearMarks: () => {},
|
|
measure: () => {},
|
|
clearMeasures: () => {},
|
|
now: () => {
|
|
const performanceNow = global.nativePerformanceNow || Date.now;
|
|
return performanceNow();
|
|
},
|
|
};
|
|
}
|
|
}
|