Only save per-thread events when non-empty
PiperOrigin-RevId: 283439027 Change-Id: I33118a45a69fff30b3c29d927c8a8380536dd1af
This commit is contained in:
parent
6a0e85b2da
commit
71681bd691
@ -199,7 +199,9 @@ void TraceMeRecorder::RegisterThread(int32 tid, ThreadLocalRecorder* thread) {
|
||||
void TraceMeRecorder::UnregisterThread(TraceMeRecorder::ThreadEvents&& events) {
|
||||
mutex_lock lock(mutex_);
|
||||
threads_.erase(events.thread.tid);
|
||||
orphaned_events_.push_back(std::move(events));
|
||||
if (!events.events.empty()) {
|
||||
orphaned_events_.push_back(std::move(events));
|
||||
}
|
||||
}
|
||||
|
||||
// This method is performance critical and should be kept fast. It is called
|
||||
@ -211,7 +213,10 @@ TraceMeRecorder::Events TraceMeRecorder::Clear() {
|
||||
std::swap(orphaned_events_, result);
|
||||
for (const auto& entry : threads_) {
|
||||
auto* recorder = entry.second;
|
||||
result.push_back(recorder->Clear());
|
||||
TraceMeRecorder::ThreadEvents events = recorder->Clear();
|
||||
if (!events.events.empty()) {
|
||||
result.push_back(std::move(events));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user