From 007cefd94ed8a9ec4936530a875091bae8ff99e2 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Fri, 4 Apr 2025 03:21:08 -0700 Subject: [PATCH] Cache performanceNow method Summary: Changelog: [Internal] Reviewed By: lenaic Differential Revision: D72410946 fbshipit-source-id: 7097e7bf6ac613adccce7fe1267fb70785f976b3 --- .../Libraries/__tests__/__snapshots__/public-api-test.js.snap | 2 +- .../src/private/webapis/performance/Performance.js | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index bde6840b596..65f281db5f7 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -9863,7 +9863,7 @@ declare export default class Performance { endMark?: string ): PerformanceMeasure; clearMeasures(measureName?: string): void; - now(): DOMHighResTimeStamp; + now: () => DOMHighResTimeStamp; getEntries(): PerformanceEntryList; getEntriesByType(entryType: PerformanceEntryType): PerformanceEntryList; getEntriesByName( diff --git a/packages/react-native/src/private/webapis/performance/Performance.js b/packages/react-native/src/private/webapis/performance/Performance.js index 98d31db72fe..c889da2468d 100644 --- a/packages/react-native/src/private/webapis/performance/Performance.js +++ b/packages/react-native/src/private/webapis/performance/Performance.js @@ -226,9 +226,7 @@ export default class Performance { * Returns a double, measured in milliseconds. * https://developer.mozilla.org/en-US/docs/Web/API/Performance/now */ - now(): DOMHighResTimeStamp { - return getCurrentTimeStamp(); - } + now: () => DOMHighResTimeStamp = getCurrentTimeStamp; /** * An extension that allows to get back to JS all currently logged marks/measures