diff options
author | Chris Lattner <sabre@nondot.org> | 2003-05-09 20:05:44 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-05-09 20:05:44 +0000 |
commit | f205fec78ae79707464d568bad297bc69fd1db78 (patch) | |
tree | 53a0f5fc6cf4053d51f63c2f76a4d3de70d9f993 /lib/Support/Statistic.cpp | |
parent | e0d8daadad8211133ae672b8dd7c445ad558a125 (diff) |
Add a new info-output-file option (hidden from --help) which is to be used by
the testing scripts to avoid breaking diffs while still gathering stats.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6067 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Statistic.cpp')
-rw-r--r-- | lib/Support/Statistic.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/Support/Statistic.cpp b/lib/Support/Statistic.cpp index f6645c6ae4..1141086c3f 100644 --- a/lib/Support/Statistic.cpp +++ b/lib/Support/Statistic.cpp @@ -20,6 +20,9 @@ #include <sstream> #include <algorithm> +// GetLibSupportInfoOutputFile - Return a file stream to print our output on... +std::ostream *GetLibSupportInfoOutputFile(); + bool DebugFlag; // DebugFlag - Exported boolean set by the -debug option unsigned StatisticBase::NumStats = 0; @@ -49,11 +52,12 @@ struct StatRecord { return std::strcmp(Name, SR.Name) < 0; } - void print(unsigned ValFieldSize, unsigned NameFieldSize) { - std::cerr << std::string(ValFieldSize-Value.length(), ' ') - << Value << " " << Name - << std::string(NameFieldSize-std::strlen(Name), ' ') - << " - " << Desc << "\n"; + void print(unsigned ValFieldSize, unsigned NameFieldSize, + std::ostream &OS) { + OS << std::string(ValFieldSize-Value.length(), ' ') + << Value << " " << Name + << std::string(NameFieldSize-std::strlen(Name), ' ') + << " - " << Desc << "\n"; } }; @@ -71,6 +75,8 @@ void StatisticBase::destroy() const { } if (--NumStats == 0 && AccumStats) { + std::ostream *OutStream = GetLibSupportInfoOutputFile(); + // Figure out how long the biggest Value and Name fields are... unsigned MaxNameLen = 0, MaxValLen = 0; for (unsigned i = 0, e = AccumStats->size(); i != e; ++i) { @@ -84,18 +90,20 @@ void StatisticBase::destroy() const { std::stable_sort(AccumStats->begin(), AccumStats->end()); // Print out the statistics header... - std::cerr << "===" << std::string(73, '-') << "===\n" - << " ... Statistics Collected ...\n" - << "===" << std::string(73, '-') << "===\n\n"; + *OutStream << "===" << std::string(73, '-') << "===\n" + << " ... Statistics Collected ...\n" + << "===" << std::string(73, '-') << "===\n\n"; // Print all of the statistics accumulated... for (unsigned i = 0, e = AccumStats->size(); i != e; ++i) - (*AccumStats)[i].print(MaxValLen, MaxNameLen); + (*AccumStats)[i].print(MaxValLen, MaxNameLen, *OutStream); - std::cerr << std::endl; // Flush the output stream... + *OutStream << std::endl; // Flush the output stream... // Free all accumulated statistics... delete AccumStats; AccumStats = 0; + if (OutStream != &std::cerr && OutStream != &std::cout) + delete OutStream; // Close the file... } } |