9#ifndef LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TASKTIMER_H
10#define LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TASKTIMER_H
13#include "llvm/ADT/DenseMap.h"
14#include "llvm/ADT/StringRef.h"
17#include <unordered_map>
20namespace trace_intel_pt {
36 template <
typename C>
auto TimeTask(llvm::StringRef name, C task) {
37 auto start = std::chrono::steady_clock::now();
39 auto end = std::chrono::steady_clock::now();
40 std::chrono::milliseconds duration =
41 std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
52 std::chrono::milliseconds duration)>
56 std::unordered_map<std::string, std::chrono::milliseconds>
m_timed_tasks;
Class used to track the duration of long running tasks related to a single scope for reporting.
void ForEachTimedTask(std::function< void(const std::string &name, std::chrono::milliseconds duration)> callback)
Executive the given callback on each recorded task.
auto TimeTask(llvm::StringRef name, C task)
Execute the given task and record its duration.
std::unordered_map< std::string, std::chrono::milliseconds > m_timed_tasks
Class used to track the duration of long running tasks for reporting.
ScopedTaskTimer & ForGlobal()
ScopedTaskTimer & ForThread(lldb::tid_t tid)
llvm::DenseMap< lldb::tid_t, ScopedTaskTimer > m_thread_timers
ScopedTaskTimer m_global_timer
A class that represents a running process on the host machine.