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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70215
91177308-0d34-0410-b5e6-
96231b3b80d8
struct PerRecordStats {
unsigned NumInstances;
struct PerRecordStats {
unsigned NumInstances;
+ unsigned NumAbbrev;
+ uint64_t TotalBits;
+
+ PerRecordStats() : NumInstances(0), NumAbbrev(0), TotalBits(0) {}
};
struct PerBlockIDStats {
};
struct PerBlockIDStats {
if (Stream.AtEndOfStream())
return Error("Premature end of bitstream");
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) {
// Read the code for this record.
unsigned AbbrevID = Stream.ReadCode();
switch (AbbrevID) {
unsigned BlobLen = 0;
unsigned Code = Stream.ReadRecord(AbbrevID, Record, BlobStart, BlobLen);
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++;
// 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 =
if (Dump) {
std::cerr << Indent << " <";
if (const char *CodeName =
std::reverse(FreqPairs.begin(), FreqPairs.end());
std::cerr << "\tRecord Histogram:\n";
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) {
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))
if (const char *CodeName =
GetCodeName(FreqPairs[i].second, I->first, StreamFile))