mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
14e69db482
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/35526 [Changelog][Internal] This closes the full loop according to the [technical design](https://fb.quip.com/MdqgAk1Eb2dV) of the WebPerf API implementation, with the main components and the working central data flow in place. The next step is to add some buffering/throttling, as in this diff we just spawn an idle-priority task after every performance entry coming (even though they still naturally do come in batches, because they manage to accumulate before the task is executed). Reviewed By: christophpurrer Differential Revision: D41496082 fbshipit-source-id: 5fd4cf22e75806f7bc98d1d1b6691596ccadf8b9
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
/*
|
|
* 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 <react/bridging/Function.h>
|
|
#include <array>
|
|
#include <optional>
|
|
#include "NativePerformanceObserver.h"
|
|
|
|
namespace facebook::react {
|
|
|
|
enum class PerformanceEntryType {
|
|
UNDEFINED = 0,
|
|
MARK = 1,
|
|
_COUNT = 2,
|
|
};
|
|
|
|
class PerformanceEntryReporter {
|
|
public:
|
|
void setReportingCallback(std::optional<AsyncCallback<>> callback);
|
|
void startReporting(PerformanceEntryType entryType);
|
|
void stopReporting(PerformanceEntryType entryType);
|
|
|
|
std::vector<RawPerformanceEntry> getPendingEntries() const;
|
|
std::vector<RawPerformanceEntry> popPendingEntries();
|
|
void clearPendingEntries();
|
|
void logEntry(const RawPerformanceEntry &entry);
|
|
|
|
bool isReportingType(PerformanceEntryType entryType) const {
|
|
return reportingType_[static_cast<int>(entryType)];
|
|
}
|
|
|
|
private:
|
|
std::optional<AsyncCallback<>> callback_;
|
|
std::vector<RawPerformanceEntry> entries_;
|
|
std::array<bool, (size_t)PerformanceEntryType::_COUNT> reportingType_{false};
|
|
};
|
|
|
|
} // namespace facebook::react
|