aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lldb/source/Plugins/Trace/intel-pt/TaskTimer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/lldb/source/Plugins/Trace/intel-pt/TaskTimer.cpp')
-rw-r--r--contrib/llvm-project/lldb/source/Plugins/Trace/intel-pt/TaskTimer.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/contrib/llvm-project/lldb/source/Plugins/Trace/intel-pt/TaskTimer.cpp b/contrib/llvm-project/lldb/source/Plugins/Trace/intel-pt/TaskTimer.cpp
new file mode 100644
index 000000000000..55d48ae35ff0
--- /dev/null
+++ b/contrib/llvm-project/lldb/source/Plugins/Trace/intel-pt/TaskTimer.cpp
@@ -0,0 +1,32 @@
+//===-- TaskTimer.cpp -----------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#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; }