[cfe-commits] r130380 - in /cfe/trunk: include/clang-c/Index.h include/clang/Basic/SourceManager.h tools/libclang/CIndex.cpp
Ted Kremenek
kremenek at apple.com
Wed Apr 27 21:10:31 PDT 2011
Author: kremenek
Date: Wed Apr 27 23:10:31 2011
New Revision: 130380
URL: http://llvm.org/viewvc/llvm-project?rev=130380&view=rev
Log:
Enhance clang_getCXTUResourceUsage() to report the amount of memory used by SourceManager's content cache allocator.
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/tools/libclang/CIndex.cpp
Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=130380&r1=130379&r2=130380&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed Apr 27 23:10:31 2011
@@ -1021,13 +1021,14 @@
CXTUResourceUsage_Identifiers = 2,
CXTUResourceUsage_Selectors = 3,
CXTUResourceUsage_GlobalCompletionResults = 4,
+ CXTUResourceUsage_SourceManagerContentCache = 5,
CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
CXTUResourceUsage_MEMORY_IN_BYTES_END =
- CXTUResourceUsage_GlobalCompletionResults,
+ CXTUResourceUsage_SourceManagerContentCache,
CXTUResourceUsage_First = CXTUResourceUsage_AST,
- CXTUResourceUsage_Last = CXTUResourceUsage_GlobalCompletionResults
+ CXTUResourceUsage_Last = CXTUResourceUsage_SourceManagerContentCache
};
/**
Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=130380&r1=130379&r2=130380&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Wed Apr 27 23:10:31 2011
@@ -850,6 +850,16 @@
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.
//===--------------------------------------------------------------------===//
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=130380&r1=130379&r2=130380&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed Apr 27 23:10:31 2011
@@ -5220,6 +5220,9 @@
case CXTUResourceUsage_GlobalCompletionResults:
str = "Code completion: cached global results";
break;
+ case CXTUResourceUsage_SourceManagerContentCache:
+ str = "SourceManager: content cache allocator";
+ break;
}
return str;
}
@@ -5252,8 +5255,14 @@
astUnit->getCachedCompletionAllocator().getPtr()) {
completionBytes = completionAllocator-> getTotalMemory();
}
- createCXTUResourceUsageEntry(*entries, CXTUResourceUsage_GlobalCompletionResults,
- completionBytes);
+ createCXTUResourceUsageEntry(*entries,
+ CXTUResourceUsage_GlobalCompletionResults,
+ 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(),
More information about the cfe-commits
mailing list