11#include "llvm/ADT/StringRef.h"
19size_t traverseTree(
const MemoryTree &MT, std::string &ComponentName,
20 const trace::Metric &
Out) {
21 size_t OriginalLen = ComponentName.size();
22 if (!ComponentName.empty())
24 size_t Total = MT.self();
25 for (
const auto &
Entry : MT.children()) {
26 ComponentName +=
Entry.first;
28 ComponentName.resize(OriginalLen + 1);
30 ComponentName.resize(OriginalLen);
36MemoryTree &MemoryTree::createChild(llvm::StringRef
Name) {
37 auto &Child = Children.try_emplace(
Name, DetailAlloc).first->getSecond();
41const llvm::DenseMap<llvm::StringRef, MemoryTree> &
48 for (
const auto &
Entry : Children)
55 traverseTree(MT, RootName,
Out);
llvm::SmallString< 256U > Name
CompiledFragmentImpl & Out
void record(const MemoryTree &MT, std::string RootName, const trace::Metric &Out)
Records total memory usage of each node under Out.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
A tree that can be used to represent memory usage of nested components while preserving the hierarchy...
size_t total() const
Returns total number of bytes used by this sub-tree. Performs a traversal.
const llvm::DenseMap< llvm::StringRef, MemoryTree > & children() const
Returns edges to direct children of this node.
Represents measurements of clangd events, e.g.