diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-22 22:34:57 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-22 22:34:57 +0000 |
commit | 2512308525ff328aa992da0b5ee14a488d2ea93a (patch) | |
tree | cf015d05abaaf869a3c8bb5dffe871d8f6213db5 | |
parent | 4c5fcd946971756bd644fe76511f292e10225981 (diff) |
Add PCH statistics for the number/percent of lexical/visible declcontexts read
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69835 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Frontend/PCHReader.h | 10 | ||||
-rw-r--r-- | include/clang/Frontend/PCHWriter.h | 8 | ||||
-rw-r--r-- | lib/Frontend/PCHReader.cpp | 12 | ||||
-rw-r--r-- | lib/Frontend/PCHWriter.cpp | 7 |
4 files changed, 35 insertions, 2 deletions
diff --git a/include/clang/Frontend/PCHReader.h b/include/clang/Frontend/PCHReader.h index 72ca6ad569..107779aa1d 100644 --- a/include/clang/Frontend/PCHReader.h +++ b/include/clang/Frontend/PCHReader.h @@ -185,9 +185,16 @@ private: /// \brief The number of macros de-serialized from the PCH file. unsigned NumMacrosRead; + /// \brief The total number of macros stored in the PCH file. unsigned TotalNumMacros; + /// Number of lexical decl contexts read/total. + unsigned NumLexicalDeclContextsRead, TotalLexicalDeclContexts; + + /// Number of visible decl contexts read/total. + unsigned NumVisibleDeclContextsRead, TotalVisibleDeclContexts; + /// \brief FIXME: document! llvm::SmallVector<uint64_t, 4> SpecialTypes; @@ -211,7 +218,8 @@ public: explicit PCHReader(Preprocessor &PP, ASTContext &Context) : SemaObj(0), PP(PP), Context(Context), Consumer(0), - IdentifierTableData(0), NumStatementsRead(0) { } + IdentifierTableData(0), NumStatementsRead(0), NumMacrosRead(0), + NumLexicalDeclContextsRead(0), NumVisibleDeclContextsRead(0) { } ~PCHReader() {} diff --git a/include/clang/Frontend/PCHWriter.h b/include/clang/Frontend/PCHWriter.h index d721f1077f..e3d0603e08 100644 --- a/include/clang/Frontend/PCHWriter.h +++ b/include/clang/Frontend/PCHWriter.h @@ -136,6 +136,14 @@ private: /// \brief The number of macros written to the PCH file. unsigned NumMacros; + /// \brief The number of lexical declcontexts written to the PCH + /// file. + unsigned NumLexicalDeclContexts; + + /// \brief The number of visible declcontexts written to the PCH + /// file. + unsigned NumVisibleDeclContexts; + void WriteTargetTriple(const TargetInfo &Target); void WriteLanguageOptions(const LangOptions &LangOpts); void WriteSourceManagerBlock(SourceManager &SourceMgr); diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 66a849d576..3ade493b4e 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -1711,6 +1711,8 @@ PCHReader::ReadPCHBlock(uint64_t &PreprocessorBlockOffset) { case pch::STATISTICS: TotalNumStatements = Record[0]; TotalNumMacros = Record[1]; + TotalLexicalDeclContexts = Record[2]; + TotalVisibleDeclContexts = Record[3]; break; case pch::TENTATIVE_DEFINITIONS: @@ -2439,6 +2441,7 @@ bool PCHReader::ReadDeclsLexicallyInContext(DeclContext *DC, // Load all of the declaration IDs Decls.clear(); Decls.insert(Decls.end(), Record.begin(), Record.end()); + ++NumLexicalDeclContextsRead; return false; } @@ -2479,6 +2482,7 @@ bool PCHReader::ReadDeclsVisibleInContext(DeclContext *DC, LoadedDecls.push_back(Record[Idx++]); } + ++NumVisibleDeclContextsRead; return false; } @@ -2525,6 +2529,14 @@ void PCHReader::PrintStats() { std::fprintf(stderr, " %u/%u macros read (%f%%)\n", NumMacrosRead, TotalNumMacros, ((float)NumMacrosRead/TotalNumMacros * 100)); + std::fprintf(stderr, " %u/%u lexical declcontexts read (%f%%)\n", + NumLexicalDeclContextsRead, TotalLexicalDeclContexts, + ((float)NumLexicalDeclContextsRead/TotalLexicalDeclContexts + * 100)); + std::fprintf(stderr, " %u/%u visible declcontexts read (%f%%)\n", + NumVisibleDeclContextsRead, TotalVisibleDeclContexts, + ((float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts + * 100)); std::fprintf(stderr, "\n"); } diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index 0aada62599..6557ca5c42 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -1616,6 +1616,7 @@ uint64_t PCHWriter::WriteDeclContextLexicalBlock(ASTContext &Context, D != DEnd; ++D) AddDeclRef(*D, Record); + ++NumLexicalDeclContexts; Stream.EmitRecord(pch::DECL_CONTEXT_LEXICAL, Record); return Offset; } @@ -1664,6 +1665,7 @@ uint64_t PCHWriter::WriteDeclContextVisibleBlock(ASTContext &Context, return 0; Stream.EmitRecord(pch::DECL_CONTEXT_VISIBLE, Record); + ++NumVisibleDeclContexts; return Offset; } @@ -1997,7 +1999,8 @@ void PCHWriter::SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset) { PCHWriter::PCHWriter(llvm::BitstreamWriter &Stream) : Stream(Stream), NextTypeID(pch::NUM_PREDEF_TYPE_IDS), - NumStatements(0), NumMacros(0) { } + NumStatements(0), NumMacros(0), NumLexicalDeclContexts(0), + NumVisibleDeclContexts(0) { } void PCHWriter::WritePCH(Sema &SemaRef) { ASTContext &Context = SemaRef.Context; @@ -2078,6 +2081,8 @@ void PCHWriter::WritePCH(Sema &SemaRef) { Record.clear(); Record.push_back(NumStatements); Record.push_back(NumMacros); + Record.push_back(NumLexicalDeclContexts); + Record.push_back(NumVisibleDeclContexts); Stream.EmitRecord(pch::STATISTICS, Record); Stream.ExitBlock(); } |