mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
70fb2dce45
Summary: This diff adds new performance API `memory`, which is a read-only property that gets the current JS heap size from native side. Note that the JSI API returns an unordered map with unknown list of memory information, which is different from the [web spec](https://fburl.com/p0vpbt33). We may enforce specific memory info type on the JSI API so that it can be properly translate to the web spec. - Update the JS spec - Update Native implementation and return memory information with JSI API `jsi::instrumentation()::getHeapInfo()` - Add native performance module to catalyst package Changelog: [General][Added] - Add performance memory API with native memory Info Reviewed By: rubennorte Differential Revision: D43137071 fbshipit-source-id: 319f1a6ba78fce61e665b00849ecf2579094af83
34 lines
912 B
JavaScript
34 lines
912 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
|
|
* @format
|
|
*/
|
|
|
|
import type {TurboModule} from '../TurboModule/RCTExport';
|
|
|
|
import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
|
|
|
|
export type NativeMemoryInfo = {[key: string]: number};
|
|
|
|
export interface Spec extends TurboModule {
|
|
+mark: (name: string, startTime: number, duration: number) => void;
|
|
+clearMarks: (markName?: string) => void;
|
|
|
|
+measure: (
|
|
name: string,
|
|
startTime: number,
|
|
endTime: number,
|
|
duration?: number,
|
|
startMark?: string,
|
|
endMark?: string,
|
|
) => void;
|
|
+clearMeasures: (measureName?: string) => void;
|
|
+getSimpleMemoryInfo: () => NativeMemoryInfo;
|
|
}
|
|
|
|
export default (TurboModuleRegistry.get<Spec>('NativePerformanceCxx'): ?Spec);
|