[llvm-commits] [llvm] r70215 - /llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
Chris Lattner
sabre at nondot.org
Mon Apr 27 11:15:28 PDT 2009
Author: lattner
Date: Mon Apr 27 13:15:27 2009
New Revision: 70215
URL: http://llvm.org/viewvc/llvm-project?rev=70215&view=rev
Log:
Print statistics for each record kind saying the number of bits
and % abbreviated. For example:
Record Histogram:
Count # Bits % Abv Record Kind
25738 3424174 100.00 SM_SLOC_INSTANTIATION_ENTRY
814 562079 100.00 SM_SLOC_FILE_ENTRY
798 34110 SM_HEADER_FILE_INFO
3 91104 100.00 SM_SLOC_BUFFER_BLOB
3 498 100.00 SM_SLOC_BUFFER_ENTRY
1 465 SM_LINE_TABLE
Modified:
llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
Modified: llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp?rev=70215&r1=70214&r2=70215&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp (original)
+++ llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Mon Apr 27 13:15:27 2009
@@ -247,6 +247,10 @@
struct PerRecordStats {
unsigned NumInstances;
+ unsigned NumAbbrev;
+ uint64_t TotalBits;
+
+ PerRecordStats() : NumInstances(0), NumAbbrev(0), TotalBits(0) {}
};
struct PerBlockIDStats {
@@ -332,6 +336,8 @@
if (Stream.AtEndOfStream())
return Error("Premature end of bitstream");
+ uint64_t RecordStartBit = Stream.GetCurrentBitNo();
+
// Read the code for this record.
unsigned AbbrevID = Stream.ReadCode();
switch (AbbrevID) {
@@ -375,11 +381,17 @@
unsigned BlobLen = 0;
unsigned Code = Stream.ReadRecord(AbbrevID, Record, BlobStart, BlobLen);
+
+
// Increment the # occurrences of this code.
if (BlockStats.CodeFreq.size() <= Code)
BlockStats.CodeFreq.resize(Code+1);
BlockStats.CodeFreq[Code].NumInstances++;
-
+ BlockStats.CodeFreq[Code].TotalBits +=
+ Stream.GetCurrentBitNo()-RecordStartBit;
+ if (AbbrevID != bitc::UNABBREV_RECORD)
+ BlockStats.CodeFreq[Code].NumAbbrev++;
+
if (Dump) {
std::cerr << Indent << " <";
if (const char *CodeName =
@@ -545,9 +557,18 @@
std::reverse(FreqPairs.begin(), FreqPairs.end());
std::cerr << "\tRecord Histogram:\n";
- fprintf(stderr, "\t\t Count Record Kind\n");
+ fprintf(stderr, "\t\t Count # Bits %% Abv Record Kind\n");
for (unsigned i = 0, e = FreqPairs.size(); i != e; ++i) {
- fprintf(stderr, "\t\t%7d ", FreqPairs[i].first);
+ const PerRecordStats &RecStats = Stats.CodeFreq[FreqPairs[i].second];
+
+ fprintf(stderr, "\t\t%7d %9llu ", RecStats.NumInstances,
+ RecStats.TotalBits);
+
+ if (RecStats.NumAbbrev)
+ fprintf(stderr, "%7.2f ",
+ (double)RecStats.NumAbbrev/RecStats.NumInstances*100);
+ else
+ fprintf(stderr, " ");
if (const char *CodeName =
GetCodeName(FreqPairs[i].second, I->first, StreamFile))
More information about the llvm-commits
mailing list