/* * 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. */ #pragma once #include #include #include #include "NativePerformanceObserver.h" namespace facebook::react { class PerformanceEntryReporter; #pragma mark - Structs #pragma mark - implementation class NativePerformance : public NativePerformanceCxxSpec, std::enable_shared_from_this { public: NativePerformance(std::shared_ptr jsInvoker); void mark(jsi::Runtime& rt, std::string name, double startTime); void measure( jsi::Runtime& rt, std::string name, double startTime, double endTime, std::optional duration, std::optional startMark, std::optional endMark); // To align with web API, we will make sure to return three properties // (jsHeapSizeLimit, totalJSHeapSize, usedJSHeapSize) + anything needed from // the VM side. // `jsHeapSizeLimit`: The maximum size of the heap, in bytes, that // is available to the context. // `totalJSHeapSize`: The total allocated heap size, in bytes. // `usedJSHeapSize`: The currently active segment of JS heap, in // bytes. // // Note that we use int64_t here and it's ok to lose precision in JS doubles // for heap size information, as double's 2^53 sig bytes is large enough. std::unordered_map getSimpleMemoryInfo(jsi::Runtime& rt); // Collect and return the RN app startup timing information for performance // tracking. std::unordered_map getReactNativeStartupTiming( jsi::Runtime& rt); private: }; } // namespace facebook::react