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 | b0e59589617e1f2587d6a54ef1b6db2ff15ab15e (patch) | |
tree | e0d571eecce51a239f37745544dd431f8eef7d27 /llvm/lib/Support/Statistic.cpp | |
parent | ad4de973be1f2ffb023abd4a6ab214f1e0dd1cb9 (diff) | |
download | bcm5719-llvm-b0e59589617e1f2587d6a54ef1b6db2ff15ab15e.tar.gz bcm5719-llvm-b0e59589617e1f2587d6a54ef1b6db2ff15ab15e.zip |
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.
llvm-svn: 6067
Diffstat (limited to 'llvm/lib/Support/Statistic.cpp')
-rw-r--r-- | llvm/lib/Support/Statistic.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/llvm/lib/Support/Statistic.cpp b/llvm/lib/Support/Statistic.cpp index f6645c6ae40..1141086c3f3 100644 --- a/llvm/lib/Support/Statistic.cpp +++ b/llvm/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... } } |