Enhance clang_getCXTUResourceUsage() to report the amount of memory used by SourceManager's content cache allocator.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130380 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2011-04-28 04:10:31 +00:00
Родитель d7f02df6e9
Коммит 457aaf0692
3 изменённых файлов: 24 добавлений и 4 удалений

Просмотреть файл

@ -1021,13 +1021,14 @@ enum CXTUResourceUsageKind {
CXTUResourceUsage_Identifiers = 2, CXTUResourceUsage_Identifiers = 2,
CXTUResourceUsage_Selectors = 3, CXTUResourceUsage_Selectors = 3,
CXTUResourceUsage_GlobalCompletionResults = 4, CXTUResourceUsage_GlobalCompletionResults = 4,
CXTUResourceUsage_SourceManagerContentCache = 5,
CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST, CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
CXTUResourceUsage_MEMORY_IN_BYTES_END = CXTUResourceUsage_MEMORY_IN_BYTES_END =
CXTUResourceUsage_GlobalCompletionResults, CXTUResourceUsage_SourceManagerContentCache,
CXTUResourceUsage_First = CXTUResourceUsage_AST, CXTUResourceUsage_First = CXTUResourceUsage_AST,
CXTUResourceUsage_Last = CXTUResourceUsage_GlobalCompletionResults CXTUResourceUsage_Last = CXTUResourceUsage_SourceManagerContentCache
}; };
/** /**

Просмотреть файл

@ -849,6 +849,16 @@ public:
/// \brief Retrieve the stored line table. /// \brief Retrieve the stored line table.
LineTableInfo &getLineTable(); LineTableInfo &getLineTable();
//===--------------------------------------------------------------------===//
// Queries for performance analysis.
//===--------------------------------------------------------------------===//
/// Return the total amount of physical memory allocated by the
/// ContentCache allocator.
size_t getContentCacheSize() const {
return ContentCacheAlloc.getTotalMemory();
}
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Other miscellaneous methods. // Other miscellaneous methods.
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//

Просмотреть файл

@ -5220,6 +5220,9 @@ const char *clang_getTUResourceUsageName(CXTUResourceUsageKind kind) {
case CXTUResourceUsage_GlobalCompletionResults: case CXTUResourceUsage_GlobalCompletionResults:
str = "Code completion: cached global results"; str = "Code completion: cached global results";
break; break;
case CXTUResourceUsage_SourceManagerContentCache:
str = "SourceManager: content cache allocator";
break;
} }
return str; return str;
} }
@ -5252,9 +5255,15 @@ CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU) {
astUnit->getCachedCompletionAllocator().getPtr()) { astUnit->getCachedCompletionAllocator().getPtr()) {
completionBytes = completionAllocator-> getTotalMemory(); completionBytes = completionAllocator-> getTotalMemory();
} }
createCXTUResourceUsageEntry(*entries, CXTUResourceUsage_GlobalCompletionResults, createCXTUResourceUsageEntry(*entries,
CXTUResourceUsage_GlobalCompletionResults,
completionBytes); completionBytes);
// How much memory is being used by SourceManager's content cache?
createCXTUResourceUsageEntry(*entries,
CXTUResourceUsage_SourceManagerContentCache,
(unsigned long) astContext.getSourceManager().getContentCacheSize());
CXTUResourceUsage usage = { (void*) entries.get(), CXTUResourceUsage usage = { (void*) entries.get(),
(unsigned) entries->size(), (unsigned) entries->size(),