Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/llvm-project/lldb/source/Plugins/Trace/intel-pt/TaskTimer.cpp
39645 views
1
//===-- TaskTimer.cpp -----------------------------------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "TaskTimer.h"
10
11
using namespace lldb;
12
using namespace lldb_private;
13
using namespace lldb_private::trace_intel_pt;
14
using namespace llvm;
15
16
void ScopedTaskTimer::ForEachTimedTask(
17
std::function<void(const std::string &event,
18
std::chrono::milliseconds duration)>
19
callback) {
20
for (const auto &kv : m_timed_tasks) {
21
callback(kv.first, kv.second);
22
}
23
}
24
25
ScopedTaskTimer &TaskTimer::ForThread(lldb::tid_t tid) {
26
auto it = m_thread_timers.find(tid);
27
if (it == m_thread_timers.end())
28
it = m_thread_timers.try_emplace(tid, ScopedTaskTimer{}).first;
29
return it->second;
30
}
31
32
ScopedTaskTimer &TaskTimer::ForGlobal() { return m_global_timer; }
33
34