/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/ReactCxxPlatform/react/profiling/FrameStats.h
47 строк
1 KB
Andrew Datsenko
move rncxx profiling (#50651)
11 апр 2025, 22:07
11 апр 2025, 22:07
14fdf32
Код
Авторство
О чём код?
/* * 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 <chrono> #include "perfetto.h" #define RENDER_FRAME_EVENT() \ TRACE_EVENT("rncxx", "render"); \ facebook::react::FrameStatsBlock __frameStatsBlock_##__LINE__; #define PROCESS_FRAME_EVENT() \ TRACE_EVENT("rncxx", "frame"); \ facebook::react::FrameStatsBlock __frameStatsBlock_##__LINE__; namespace facebook::react { class TimeSeries; void enableFrameStatsPrinting(bool enable = true); void logFrameStats(double timeStampMs, double durationMs); inline double getTimeStampMs() { return std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now().time_since_epoch()) .count() / 1000000.0; } class FrameStatsBlock { public: FrameStatsBlock() : startTimeStamp_(getTimeStampMs()) {} ~FrameStatsBlock() { logFrameStats(startTimeStamp_, getTimeStampMs() - startTimeStamp_); } private: double startTimeStamp_; }; } // namespace facebook::react