| OLD | NEW |
| 1 //===- subzero/src/IceTimerTree.cpp - Pass timer defs ---------------------===// | 1 //===- subzero/src/IceTimerTree.cpp - Pass timer defs ---------------------===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 /// | 9 /// |
| 10 /// \file | 10 /// \file |
| 11 /// \brief Defines the TimerTree class, which tracks flat and cumulative | 11 /// \brief Defines the TimerTree class, which tracks flat and cumulative |
| 12 /// execution time collection of call chains. | 12 /// execution time collection of call chains. |
| 13 /// | 13 /// |
| 14 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
| 15 | 15 |
| 16 #include "IceTimerTree.h" | 16 #include "IceTimerTree.h" |
| 17 | 17 |
| 18 #include "IceDefs.h" | 18 #include "IceDefs.h" |
| 19 | 19 |
| 20 #ifdef __clang__ | 20 #ifdef __clang__ |
| 21 #pragma clang diagnostic push | 21 #pragma clang diagnostic push |
| 22 #pragma clang diagnostic ignored "-Wunused-parameter" | 22 #pragma clang diagnostic ignored "-Wunused-parameter" |
| 23 #endif // __clang__ | 23 #endif // __clang__ |
| 24 | 24 |
| 25 #include "llvm/Support/Format.h" |
| 25 #include "llvm/Support/Timer.h" | 26 #include "llvm/Support/Timer.h" |
| 26 | 27 |
| 27 #ifdef __clang__ | 28 #ifdef __clang__ |
| 28 #pragma clang diagnostic pop | 29 #pragma clang diagnostic pop |
| 29 #endif // __clang__ | 30 #endif // __clang__ |
| 30 | 31 |
| 31 namespace Ice { | 32 namespace Ice { |
| 32 | 33 |
| 33 TimerStack::TimerStack(const std::string &Name) | 34 TimerStack::TimerStack(const std::string &Name) |
| 34 : Name(Name), FirstTimestamp(timestamp()), LastTimestamp(FirstTimestamp) { | 35 : Name(Name), FirstTimestamp(timestamp()), LastTimestamp(FirstTimestamp) { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 225 |
| 225 namespace { | 226 namespace { |
| 226 | 227 |
| 227 using DumpMapType = std::multimap<double, std::string>; | 228 using DumpMapType = std::multimap<double, std::string>; |
| 228 | 229 |
| 229 // Dump the Map items in reverse order of their time contribution. | 230 // Dump the Map items in reverse order of their time contribution. |
| 230 void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) { | 231 void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) { |
| 231 if (!BuildDefs::timers()) | 232 if (!BuildDefs::timers()) |
| 232 return; | 233 return; |
| 233 for (auto &I : reverse_range(Map)) { | 234 for (auto &I : reverse_range(Map)) { |
| 234 char buf[80]; | 235 Str << llvm::format(" %10.6f (%4.1f%%): ", I.first, |
| 235 snprintf(buf, llvm::array_lengthof(buf), " %10.6f (%4.1f%%): ", I.first, | 236 I.first * 100 / TotalTime) << I.second << "\n"; |
| 236 I.first * 100 / TotalTime); | |
| 237 Str << buf << I.second << "\n"; | |
| 238 } | 237 } |
| 239 } | 238 } |
| 240 | 239 |
| 241 // Write a printf() format string into Buf[], in the format "[%5lu] ", where | 240 // Write a printf() format string into Buf[], in the format "[%5lu] ", where |
| 242 // "5" is actually the number of digits in MaxVal. E.g., | 241 // "5" is actually the number of digits in MaxVal. E.g., |
| 243 // MaxVal=0 ==> "[%1lu] " | 242 // MaxVal=0 ==> "[%1lu] " |
| 244 // MaxVal=5 ==> "[%1lu] " | 243 // MaxVal=5 ==> "[%1lu] " |
| 245 // MaxVal=9876 ==> "[%4lu] " | 244 // MaxVal=9876 ==> "[%4lu] " |
| 246 void makePrintfFormatString(char *Buf, size_t BufLen, size_t MaxVal) { | 245 void makePrintfFormatString(char *Buf, size_t BufLen, size_t MaxVal) { |
| 247 if (!BuildDefs::timers()) | 246 if (!BuildDefs::timers()) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 dumpHelper(Str, FlatMap, TotalTime); | 306 dumpHelper(Str, FlatMap, TotalTime); |
| 308 Str << "Number of timer updates: " << StateChangeCount << "\n"; | 307 Str << "Number of timer updates: " << StateChangeCount << "\n"; |
| 309 } | 308 } |
| 310 | 309 |
| 311 double TimerStack::timestamp() { | 310 double TimerStack::timestamp() { |
| 312 // TODO: Implement in terms of std::chrono for C++11. | 311 // TODO: Implement in terms of std::chrono for C++11. |
| 313 return llvm::TimeRecord::getCurrentTime(false).getWallTime(); | 312 return llvm::TimeRecord::getCurrentTime(false).getWallTime(); |
| 314 } | 313 } |
| 315 | 314 |
| 316 } // end of namespace Ice | 315 } // end of namespace Ice |
| OLD | NEW |