-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract performance observers to native layer and push entr…
…ies to each observer
- Loading branch information
Showing
14 changed files
with
433 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
packages/react-native/ReactCommon/react/performance/timeline/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
packages/react-native/ReactCommon/react/performance/timeline/PerformanceEntryBuffer.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#include "PerformanceEntryBuffer.h" | ||
|
||
namespace facebook::react { | ||
|
||
PerformanceEntryPushStatus PerformanceEntryCircularBuffer::add(const facebook::react::PerformanceEntry&& entry) { | ||
return entries.add(std::move(entry)); | ||
} | ||
|
||
void PerformanceEntryCircularBuffer::consume(std::vector<PerformanceEntry>& target) { | ||
entries.consume(target); | ||
} | ||
|
||
size_t PerformanceEntryCircularBuffer::pendingMessagesCount() const { | ||
return entries.getNumToConsume(); | ||
} | ||
|
||
void PerformanceEntryCircularBuffer::getEntries(std::optional<std::string_view> name, std::vector<PerformanceEntry>& target) const { | ||
entries.getEntries( | ||
target, [&](const PerformanceEntry& e) { return e.name == name; }); | ||
} | ||
|
||
void PerformanceEntryCircularBuffer::clear() { | ||
entries.clear(); | ||
} | ||
|
||
|
||
void PerformanceEntryCircularBuffer::clear(std::string_view name) { | ||
entries.clear([&](const PerformanceEntry& e) { return e.name == name; }); | ||
} | ||
|
||
PerformanceEntryPushStatus PerformanceEntryKeyedBuffer::add(const facebook::react::PerformanceEntry&& entry) { | ||
entries.add(entry); | ||
return PerformanceEntryPushStatus::OK; | ||
} | ||
|
||
void PerformanceEntryKeyedBuffer::consume(std::vector<PerformanceEntry>& target) { | ||
entries.consume(target); | ||
} | ||
|
||
size_t PerformanceEntryKeyedBuffer::pendingMessagesCount() const { | ||
return entries.getNumToConsume(); | ||
} | ||
|
||
void PerformanceEntryKeyedBuffer::getEntries(std::optional<std::string_view> name, std::vector<PerformanceEntry>& target) const { | ||
if (name.has_value()) { | ||
std::string nameStr{name.value()}; | ||
entries.getEntries(nameStr, target); | ||
} else { | ||
entries.getEntries(target); | ||
} | ||
} | ||
|
||
void PerformanceEntryKeyedBuffer::clear() { | ||
entries.clear(); | ||
} | ||
|
||
void PerformanceEntryKeyedBuffer::clear(std::string_view name) { | ||
std::string nameStr{name}; | ||
entries.clear(nameStr); | ||
} | ||
|
||
} // namespace facebook::react |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.