aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Trace/intel-pt/TaskTimer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/Trace/intel-pt/TaskTimer.cpp')
-rw-r--r--lldb/source/Plugins/Trace/intel-pt/TaskTimer.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Trace/intel-pt/TaskTimer.cpp b/lldb/source/Plugins/Trace/intel-pt/TaskTimer.cpp
new file mode 100644
index 000000000000..9603b25fc81c
--- /dev/null
+++ b/lldb/source/Plugins/Trace/intel-pt/TaskTimer.cpp
@@ -0,0 +1,24 @@
+#include "TaskTimer.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::trace_intel_pt;
+using namespace llvm;
+
+void ScopedTaskTimer::ForEachTimedTask(
+ std::function<void(const std::string &event,
+ std::chrono::milliseconds duration)>
+ callback) {
+ for (const auto &kv : m_timed_tasks) {
+ callback(kv.first, kv.second);
+ }
+}
+
+ScopedTaskTimer &TaskTimer::ForThread(lldb::tid_t tid) {
+ auto it = m_thread_timers.find(tid);
+ if (it == m_thread_timers.end())
+ it = m_thread_timers.try_emplace(tid, ScopedTaskTimer{}).first;
+ return it->second;
+}
+
+ScopedTaskTimer &TaskTimer::ForGlobal() { return m_global_timer; }