LLDB mainline
TaskTimer.cpp
Go to the documentation of this file.
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
11using namespace lldb;
12using namespace lldb_private;
13using namespace lldb_private::trace_intel_pt;
14using namespace llvm;
15
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
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
Class used to track the duration of long running tasks related to a single scope for reporting.
Definition: TaskTimer.h:24
void ForEachTimedTask(std::function< void(const std::string &name, std::chrono::milliseconds duration)> callback)
Executive the given callback on each recorded task.
Definition: TaskTimer.cpp:16
std::unordered_map< std::string, std::chrono::milliseconds > m_timed_tasks
Definition: TaskTimer.h:56
ScopedTaskTimer & ForThread(lldb::tid_t tid)
Definition: TaskTimer.cpp:25
llvm::DenseMap< lldb::tid_t, ScopedTaskTimer > m_thread_timers
Definition: TaskTimer.h:71
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Definition: SBAddress.h:15
uint64_t tid_t
Definition: lldb-types.h:82
Definition: Debugger.h:53