Path: blob/main/contrib/llvm-project/lldb/source/Plugins/Trace/intel-pt/TaskTimer.cpp
39645 views
//===-- TaskTimer.cpp -----------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "TaskTimer.h"910using namespace lldb;11using namespace lldb_private;12using namespace lldb_private::trace_intel_pt;13using namespace llvm;1415void ScopedTaskTimer::ForEachTimedTask(16std::function<void(const std::string &event,17std::chrono::milliseconds duration)>18callback) {19for (const auto &kv : m_timed_tasks) {20callback(kv.first, kv.second);21}22}2324ScopedTaskTimer &TaskTimer::ForThread(lldb::tid_t tid) {25auto it = m_thread_timers.find(tid);26if (it == m_thread_timers.end())27it = m_thread_timers.try_emplace(tid, ScopedTaskTimer{}).first;28return it->second;29}3031ScopedTaskTimer &TaskTimer::ForGlobal() { return m_global_timer; }323334