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 // This file defines the TimerTree class, which tracks flat and | 10 // This file defines the TimerTree class, which tracks flat and |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } | 134 } |
135 | 135 |
136 namespace { | 136 namespace { |
137 | 137 |
138 typedef std::multimap<double, IceString> DumpMapType; | 138 typedef std::multimap<double, IceString> DumpMapType; |
139 | 139 |
140 // Dump the Map items in reverse order of their time contribution. | 140 // Dump the Map items in reverse order of their time contribution. |
141 void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) { | 141 void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) { |
142 if (!ALLOW_DUMP) | 142 if (!ALLOW_DUMP) |
143 return; | 143 return; |
144 // TODO(stichnot): Use llvm::make_range with LLVM 3.5. | 144 for (auto &I : reverse_range(Map)) { |
145 for (auto I = Map.rbegin(), E = Map.rend(); I != E; ++I) { | |
146 char buf[80]; | 145 char buf[80]; |
147 snprintf(buf, llvm::array_lengthof(buf), " %10.6f (%4.1f%%): ", I->first, | 146 snprintf(buf, llvm::array_lengthof(buf), " %10.6f (%4.1f%%): ", I.first, |
148 I->first * 100 / TotalTime); | 147 I.first * 100 / TotalTime); |
149 Str << buf << I->second << "\n"; | 148 Str << buf << I.second << "\n"; |
150 } | 149 } |
151 } | 150 } |
152 | 151 |
153 // Write a printf() format string into Buf[], in the format "[%5lu] ", | 152 // Write a printf() format string into Buf[], in the format "[%5lu] ", |
154 // where "5" is actually the number of digits in MaxVal. E.g., | 153 // where "5" is actually the number of digits in MaxVal. E.g., |
155 // MaxVal=0 ==> "[%1lu] " | 154 // MaxVal=0 ==> "[%1lu] " |
156 // MaxVal=5 ==> "[%1lu] " | 155 // MaxVal=5 ==> "[%1lu] " |
157 // MaxVal=9876 ==> "[%4lu] " | 156 // MaxVal=9876 ==> "[%4lu] " |
158 void makePrintfFormatString(char *Buf, size_t BufLen, size_t MaxVal) { | 157 void makePrintfFormatString(char *Buf, size_t BufLen, size_t MaxVal) { |
159 if (!ALLOW_DUMP) | 158 if (!ALLOW_DUMP) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 dumpHelper(Str, FlatMap, TotalTime); | 218 dumpHelper(Str, FlatMap, TotalTime); |
220 Str << "Number of timer updates: " << StateChangeCount << "\n"; | 219 Str << "Number of timer updates: " << StateChangeCount << "\n"; |
221 } | 220 } |
222 | 221 |
223 double TimerStack::timestamp() { | 222 double TimerStack::timestamp() { |
224 // TODO: Implement in terms of std::chrono for C++11. | 223 // TODO: Implement in terms of std::chrono for C++11. |
225 return llvm::TimeRecord::getCurrentTime(false).getWallTime(); | 224 return llvm::TimeRecord::getCurrentTime(false).getWallTime(); |
226 } | 225 } |
227 | 226 |
228 } // end of namespace Ice | 227 } // end of namespace Ice |
OLD | NEW |