diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-10-16 16:30:34 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-10-16 16:30:34 +0000 |
commit | cc863b2bb6bb018416a65b2f9666ca9dd07dcae5 (patch) | |
tree | e2838a4c105b98d41a5e9822d05095aa84ca25e8 /llvm/lib/Support | |
parent | cb6b02a0866b568dd83c74daddf570bade449191 (diff) | |
download | bcm5719-llvm-cc863b2bb6bb018416a65b2f9666ca9dd07dcae5.tar.gz bcm5719-llvm-cc863b2bb6bb018416a65b2f9666ca9dd07dcae5.zip |
Let printf do the formatting instead aligning strings ourselves.
While at it, merge some format strings.
llvm-svn: 142140
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/Statistic.cpp | 13 | ||||
-rw-r--r-- | llvm/lib/Support/Timer.cpp | 16 |
2 files changed, 12 insertions, 17 deletions
diff --git a/llvm/lib/Support/Statistic.cpp b/llvm/lib/Support/Statistic.cpp index 1e733d92e61..04a44a0f711 100644 --- a/llvm/lib/Support/Statistic.cpp +++ b/llvm/lib/Support/Statistic.cpp @@ -24,6 +24,7 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/Format.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/Mutex.h" @@ -126,13 +127,11 @@ void llvm::PrintStatistics(raw_ostream &OS) { << "===" << std::string(73, '-') << "===\n\n"; // Print all of the statistics. - for (size_t i = 0, e = Stats.Stats.size(); i != e; ++i) { - std::string CountStr = utostr(Stats.Stats[i]->getValue()); - OS << std::string(MaxValLen-CountStr.size(), ' ') - << CountStr << " " << Stats.Stats[i]->getName() - << std::string(MaxNameLen-std::strlen(Stats.Stats[i]->getName()), ' ') - << " - " << Stats.Stats[i]->getDesc() << "\n"; - } + for (size_t i = 0, e = Stats.Stats.size(); i != e; ++i) + OS << format("%*u %-*s - %s\n", + MaxValLen, Stats.Stats[i]->getValue(), + MaxNameLen, Stats.Stats[i]->getName(), + Stats.Stats[i]->getDesc()); OS << '\n'; // Flush the output stream. OS.flush(); diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp index a9ed5eecfa7..03ac9632f0c 100644 --- a/llvm/lib/Support/Timer.cpp +++ b/llvm/lib/Support/Timer.cpp @@ -168,10 +168,8 @@ void Timer::stopTimer() { static void printVal(double Val, double Total, raw_ostream &OS) { if (Total < 1e-7) // Avoid dividing by zero. OS << " ----- "; - else { - OS << " " << format("%7.4f", Val) << " ("; - OS << format("%5.1f", Val*100/Total) << "%)"; - } + else + OS << format(" %7.4f (%5.1f%%)", Val, Val*100/Total); } void TimeRecord::print(const TimeRecord &Total, raw_ostream &OS) const { @@ -186,7 +184,7 @@ void TimeRecord::print(const TimeRecord &Total, raw_ostream &OS) const { OS << " "; if (Total.getMemUsed()) - OS << format("%9lld", (long long)getMemUsed()) << " "; + OS << format("%9lld ", (long long)getMemUsed()); } @@ -332,11 +330,9 @@ void TimerGroup::PrintQueuedTimers(raw_ostream &OS) { // If this is not an collection of ungrouped times, print the total time. // Ungrouped timers don't really make sense to add up. We still print the // TOTAL line to make the percentages make sense. - if (this != DefaultTimerGroup) { - OS << " Total Execution Time: "; - OS << format("%5.4f", Total.getProcessTime()) << " seconds ("; - OS << format("%5.4f", Total.getWallTime()) << " wall clock)\n"; - } + if (this != DefaultTimerGroup) + OS << format(" Total Execution Time: %5.4f seconds (%5.4f wall clock)\n", + Total.getProcessTime(), Total.getWallTime()); OS << '\n'; if (Total.getUserTime()) |