Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 1 | //===- subzero/src/IceTimerTree.cpp - Pass timer defs ---------------------===// |
| 2 | // |
| 3 | // The Subzero Code Generator |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Andrew Scull | 9612d32 | 2015-07-06 14:53:25 -0700 | [diff] [blame] | 9 | /// |
| 10 | /// \file |
| 11 | /// This file defines the TimerTree class, which tracks flat and |
| 12 | /// cumulative execution time collection of call chains. |
| 13 | /// |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 14 | //===----------------------------------------------------------------------===// |
| 15 | |
John Porto | 67f8de9 | 2015-06-25 10:14:17 -0700 | [diff] [blame] | 16 | #include "IceTimerTree.h" |
Jim Stichnoth | 9c234e2 | 2014-10-01 09:28:21 -0700 | [diff] [blame] | 17 | |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 18 | #include "IceDefs.h" |
Jim Stichnoth | 98da966 | 2015-06-27 06:38:08 -0700 | [diff] [blame] | 19 | |
| 20 | #pragma clang diagnostic push |
| 21 | #pragma clang diagnostic ignored "-Wunused-parameter" |
John Porto | 67f8de9 | 2015-06-25 10:14:17 -0700 | [diff] [blame] | 22 | #include "llvm/Support/Timer.h" |
Jim Stichnoth | 98da966 | 2015-06-27 06:38:08 -0700 | [diff] [blame] | 23 | #pragma clang diagnostic pop |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 24 | |
| 25 | namespace Ice { |
| 26 | |
Jim Stichnoth | 8363a06 | 2014-10-07 10:02:38 -0700 | [diff] [blame] | 27 | TimerStack::TimerStack(const IceString &Name) |
Jim Stichnoth | eafb56c | 2015-06-22 10:35:22 -0700 | [diff] [blame] | 28 | : Name(Name), FirstTimestamp(timestamp()), LastTimestamp(FirstTimestamp) { |
Jim Stichnoth | 20b71f5 | 2015-06-24 15:52:24 -0700 | [diff] [blame] | 29 | if (!BuildDefs::dump()) |
Jim Stichnoth | 1c44d81 | 2014-12-08 14:57:52 -0800 | [diff] [blame] | 30 | return; |
Jim Stichnoth | 380d7b9 | 2015-01-30 13:10:39 -0800 | [diff] [blame] | 31 | Nodes.resize(1); // Reserve Nodes[0] for the root node (sentinel). |
Jim Stichnoth | 8363a06 | 2014-10-07 10:02:38 -0700 | [diff] [blame] | 32 | IDs.resize(TT__num); |
Jim Stichnoth | 380d7b9 | 2015-01-30 13:10:39 -0800 | [diff] [blame] | 33 | LeafTimes.resize(TT__num); |
| 34 | LeafCounts.resize(TT__num); |
Jim Stichnoth | 8363a06 | 2014-10-07 10:02:38 -0700 | [diff] [blame] | 35 | #define STR(s) #s |
| 36 | #define X(tag) \ |
| 37 | IDs[TT_##tag] = STR(tag); \ |
| 38 | IDsIndex[STR(tag)] = TT_##tag; |
| 39 | TIMERTREE_TABLE; |
| 40 | #undef X |
| 41 | #undef STR |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | // Returns the unique timer ID for the given Name, creating a new ID |
Jim Stichnoth | 8363a06 | 2014-10-07 10:02:38 -0700 | [diff] [blame] | 45 | // if needed. |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 46 | TimerIdT TimerStack::getTimerID(const IceString &Name) { |
Jim Stichnoth | 20b71f5 | 2015-06-24 15:52:24 -0700 | [diff] [blame] | 47 | if (!BuildDefs::dump()) |
Jim Stichnoth | 1c44d81 | 2014-12-08 14:57:52 -0800 | [diff] [blame] | 48 | return 0; |
Jim Stichnoth | 8363a06 | 2014-10-07 10:02:38 -0700 | [diff] [blame] | 49 | if (IDsIndex.find(Name) == IDsIndex.end()) { |
| 50 | IDsIndex[Name] = IDs.size(); |
| 51 | IDs.push_back(Name); |
Jim Stichnoth | 380d7b9 | 2015-01-30 13:10:39 -0800 | [diff] [blame] | 52 | LeafTimes.push_back(decltype(LeafTimes)::value_type()); |
| 53 | LeafCounts.push_back(decltype(LeafCounts)::value_type()); |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 54 | } |
Jim Stichnoth | 8363a06 | 2014-10-07 10:02:38 -0700 | [diff] [blame] | 55 | return IDsIndex[Name]; |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 56 | } |
| 57 | |
Jim Stichnoth | 380d7b9 | 2015-01-30 13:10:39 -0800 | [diff] [blame] | 58 | // Creates a mapping from TimerIdT (leaf) values in the Src timer |
| 59 | // stack into TimerIdT values in this timer stack. Creates new |
| 60 | // entries in this timer stack as needed. |
| 61 | TimerStack::TranslationType |
| 62 | TimerStack::translateIDsFrom(const TimerStack &Src) { |
| 63 | size_t Size = Src.IDs.size(); |
| 64 | TranslationType Mapping(Size); |
| 65 | for (TimerIdT i = 0; i < Size; ++i) { |
| 66 | Mapping[i] = getTimerID(Src.IDs[i]); |
| 67 | } |
| 68 | return Mapping; |
| 69 | } |
| 70 | |
| 71 | // Merges two timer stacks, by combining and summing corresponding |
| 72 | // entries. This timer stack is updated from Src. |
| 73 | void TimerStack::mergeFrom(const TimerStack &Src) { |
Jim Stichnoth | 20b71f5 | 2015-06-24 15:52:24 -0700 | [diff] [blame] | 74 | if (!BuildDefs::dump()) |
Jim Stichnoth | 380d7b9 | 2015-01-30 13:10:39 -0800 | [diff] [blame] | 75 | return; |
| 76 | TranslationType Mapping = translateIDsFrom(Src); |
| 77 | TTindex SrcIndex = 0; |
| 78 | for (const TimerTreeNode &SrcNode : Src.Nodes) { |
| 79 | // The first node is reserved as a sentinel, so avoid it. |
| 80 | if (SrcIndex > 0) { |
| 81 | // Find the full path to the Src node, translated to path |
| 82 | // components corresponding to this timer stack. |
| 83 | PathType MyPath = Src.getPath(SrcIndex, Mapping); |
| 84 | // Find a node in this timer stack corresponding to the given |
| 85 | // path, creating new interior nodes as necessary. |
| 86 | TTindex MyIndex = findPath(MyPath); |
| 87 | Nodes[MyIndex].Time += SrcNode.Time; |
| 88 | Nodes[MyIndex].UpdateCount += SrcNode.UpdateCount; |
| 89 | } |
| 90 | ++SrcIndex; |
| 91 | } |
| 92 | for (TimerIdT i = 0; i < Src.LeafTimes.size(); ++i) { |
| 93 | LeafTimes[Mapping[i]] += Src.LeafTimes[i]; |
| 94 | LeafCounts[Mapping[i]] += Src.LeafCounts[i]; |
| 95 | } |
| 96 | StateChangeCount += Src.StateChangeCount; |
| 97 | } |
| 98 | |
| 99 | // Constructs a path consisting of the sequence of leaf values leading |
| 100 | // to a given node, with the Mapping translation applied to the leaf |
| 101 | // values. The path ends up being in "reverse" order, i.e. from leaf |
| 102 | // to root. |
| 103 | TimerStack::PathType TimerStack::getPath(TTindex Index, |
| 104 | const TranslationType &Mapping) const { |
| 105 | PathType Path; |
| 106 | while (Index) { |
| 107 | Path.push_back(Mapping[Nodes[Index].Interior]); |
| 108 | assert(Nodes[Index].Parent < Index); |
| 109 | Index = Nodes[Index].Parent; |
| 110 | } |
| 111 | return Path; |
| 112 | } |
| 113 | |
| 114 | // Given a parent node and a leaf ID, returns the index of the |
| 115 | // parent's child ID, creating a new node for the child as necessary. |
| 116 | TimerStack::TTindex TimerStack::getChildIndex(TimerStack::TTindex Parent, |
| 117 | TimerIdT ID) { |
| 118 | if (Nodes[Parent].Children.size() <= ID) |
| 119 | Nodes[Parent].Children.resize(ID + 1); |
| 120 | if (Nodes[Parent].Children[ID] == 0) { |
| 121 | TTindex Size = Nodes.size(); |
| 122 | Nodes[Parent].Children[ID] = Size; |
| 123 | Nodes.resize(Size + 1); |
| 124 | Nodes[Size].Parent = Parent; |
| 125 | Nodes[Size].Interior = ID; |
| 126 | } |
| 127 | return Nodes[Parent].Children[ID]; |
| 128 | } |
| 129 | |
| 130 | // Finds a node in the timer stack corresponding to the given path, |
| 131 | // creating new interior nodes as necessary. |
| 132 | TimerStack::TTindex TimerStack::findPath(const PathType &Path) { |
| 133 | TTindex CurIndex = 0; |
| 134 | // The path is in reverse order (leaf to root), so it needs to be |
| 135 | // followed in reverse. |
| 136 | for (TTindex Index : reverse_range(Path)) { |
| 137 | CurIndex = getChildIndex(CurIndex, Index); |
| 138 | } |
| 139 | assert(CurIndex); // shouldn't be the sentinel node |
| 140 | return CurIndex; |
| 141 | } |
| 142 | |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 143 | // Pushes a new marker onto the timer stack. |
| 144 | void TimerStack::push(TimerIdT ID) { |
Jim Stichnoth | 20b71f5 | 2015-06-24 15:52:24 -0700 | [diff] [blame] | 145 | if (!BuildDefs::dump()) |
Jim Stichnoth | 1c44d81 | 2014-12-08 14:57:52 -0800 | [diff] [blame] | 146 | return; |
Jim Stichnoth | abce6e5 | 2014-10-14 11:09:27 -0700 | [diff] [blame] | 147 | const bool UpdateCounts = false; |
| 148 | update(UpdateCounts); |
Jim Stichnoth | 380d7b9 | 2015-01-30 13:10:39 -0800 | [diff] [blame] | 149 | StackTop = getChildIndex(StackTop, ID); |
| 150 | assert(StackTop); |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Jim Stichnoth | 380d7b9 | 2015-01-30 13:10:39 -0800 | [diff] [blame] | 153 | // Pops the top marker from the timer stack. Validates via assert() |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 154 | // that the expected marker is popped. |
| 155 | void TimerStack::pop(TimerIdT ID) { |
Jim Stichnoth | 20b71f5 | 2015-06-24 15:52:24 -0700 | [diff] [blame] | 156 | if (!BuildDefs::dump()) |
Jim Stichnoth | 1c44d81 | 2014-12-08 14:57:52 -0800 | [diff] [blame] | 157 | return; |
Jim Stichnoth | abce6e5 | 2014-10-14 11:09:27 -0700 | [diff] [blame] | 158 | const bool UpdateCounts = true; |
| 159 | update(UpdateCounts); |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 160 | assert(StackTop); |
| 161 | assert(Nodes[StackTop].Parent < StackTop); |
| 162 | // Verify that the expected ID is being popped. |
| 163 | assert(Nodes[StackTop].Interior == ID); |
| 164 | (void)ID; |
| 165 | // Verify that the parent's child points to the current stack top. |
| 166 | assert(Nodes[Nodes[StackTop].Parent].Children[ID] == StackTop); |
| 167 | StackTop = Nodes[StackTop].Parent; |
| 168 | } |
| 169 | |
| 170 | // At a state change (e.g. push or pop), updates the flat and |
| 171 | // cumulative timings for everything on the timer stack. |
Jim Stichnoth | abce6e5 | 2014-10-14 11:09:27 -0700 | [diff] [blame] | 172 | void TimerStack::update(bool UpdateCounts) { |
Jim Stichnoth | 20b71f5 | 2015-06-24 15:52:24 -0700 | [diff] [blame] | 173 | if (!BuildDefs::dump()) |
Jim Stichnoth | 1c44d81 | 2014-12-08 14:57:52 -0800 | [diff] [blame] | 174 | return; |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 175 | ++StateChangeCount; |
| 176 | // Whenever the stack is about to change, we grab the time delta |
| 177 | // since the last change and add it to all active cumulative |
| 178 | // elements and to the flat element for the top of the stack. |
| 179 | double Current = timestamp(); |
| 180 | double Delta = Current - LastTimestamp; |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 181 | if (StackTop) { |
| 182 | TimerIdT Leaf = Nodes[StackTop].Interior; |
Jim Stichnoth | abce6e5 | 2014-10-14 11:09:27 -0700 | [diff] [blame] | 183 | if (Leaf >= LeafTimes.size()) { |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 184 | LeafTimes.resize(Leaf + 1); |
Jim Stichnoth | abce6e5 | 2014-10-14 11:09:27 -0700 | [diff] [blame] | 185 | LeafCounts.resize(Leaf + 1); |
| 186 | } |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 187 | LeafTimes[Leaf] += Delta; |
Jim Stichnoth | abce6e5 | 2014-10-14 11:09:27 -0700 | [diff] [blame] | 188 | if (UpdateCounts) |
| 189 | ++LeafCounts[Leaf]; |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 190 | } |
| 191 | TTindex Prefix = StackTop; |
| 192 | while (Prefix) { |
| 193 | Nodes[Prefix].Time += Delta; |
Jim Stichnoth | abce6e5 | 2014-10-14 11:09:27 -0700 | [diff] [blame] | 194 | // Only update a leaf node count, not the internal node counts. |
| 195 | if (UpdateCounts && Prefix == StackTop) |
| 196 | ++Nodes[Prefix].UpdateCount; |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 197 | TTindex Next = Nodes[Prefix].Parent; |
| 198 | assert(Next < Prefix); |
| 199 | Prefix = Next; |
| 200 | } |
Jim Stichnoth | 4775255 | 2014-10-13 17:15:08 -0700 | [diff] [blame] | 201 | // Capture the next timestamp *after* the updates are finished. |
| 202 | // This minimizes how much the timer can perturb the reported |
| 203 | // timing. The numbers may not sum to 100%, and the missing amount |
| 204 | // is indicative of the overhead of timing. |
| 205 | LastTimestamp = timestamp(); |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 206 | } |
| 207 | |
Jim Stichnoth | d14b1a0 | 2014-10-08 08:28:36 -0700 | [diff] [blame] | 208 | void TimerStack::reset() { |
Jim Stichnoth | 20b71f5 | 2015-06-24 15:52:24 -0700 | [diff] [blame] | 209 | if (!BuildDefs::dump()) |
Jim Stichnoth | 1c44d81 | 2014-12-08 14:57:52 -0800 | [diff] [blame] | 210 | return; |
Jim Stichnoth | d14b1a0 | 2014-10-08 08:28:36 -0700 | [diff] [blame] | 211 | StateChangeCount = 0; |
| 212 | FirstTimestamp = LastTimestamp = timestamp(); |
| 213 | LeafTimes.assign(LeafTimes.size(), 0); |
Jim Stichnoth | abce6e5 | 2014-10-14 11:09:27 -0700 | [diff] [blame] | 214 | LeafCounts.assign(LeafCounts.size(), 0); |
Jim Stichnoth | d14b1a0 | 2014-10-08 08:28:36 -0700 | [diff] [blame] | 215 | for (TimerTreeNode &Node : Nodes) { |
| 216 | Node.Time = 0; |
Jim Stichnoth | abce6e5 | 2014-10-14 11:09:27 -0700 | [diff] [blame] | 217 | Node.UpdateCount = 0; |
Jim Stichnoth | d14b1a0 | 2014-10-08 08:28:36 -0700 | [diff] [blame] | 218 | } |
| 219 | } |
| 220 | |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 221 | namespace { |
| 222 | |
| 223 | typedef std::multimap<double, IceString> DumpMapType; |
| 224 | |
| 225 | // Dump the Map items in reverse order of their time contribution. |
| 226 | void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) { |
Jim Stichnoth | 20b71f5 | 2015-06-24 15:52:24 -0700 | [diff] [blame] | 227 | if (!BuildDefs::dump()) |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 228 | return; |
Jim Stichnoth | 7e57136 | 2015-01-09 11:43:26 -0800 | [diff] [blame] | 229 | for (auto &I : reverse_range(Map)) { |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 230 | char buf[80]; |
Jim Stichnoth | 7e57136 | 2015-01-09 11:43:26 -0800 | [diff] [blame] | 231 | snprintf(buf, llvm::array_lengthof(buf), " %10.6f (%4.1f%%): ", I.first, |
| 232 | I.first * 100 / TotalTime); |
| 233 | Str << buf << I.second << "\n"; |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 234 | } |
| 235 | } |
| 236 | |
Jim Stichnoth | abce6e5 | 2014-10-14 11:09:27 -0700 | [diff] [blame] | 237 | // Write a printf() format string into Buf[], in the format "[%5lu] ", |
| 238 | // where "5" is actually the number of digits in MaxVal. E.g., |
| 239 | // MaxVal=0 ==> "[%1lu] " |
| 240 | // MaxVal=5 ==> "[%1lu] " |
| 241 | // MaxVal=9876 ==> "[%4lu] " |
| 242 | void makePrintfFormatString(char *Buf, size_t BufLen, size_t MaxVal) { |
Jim Stichnoth | 20b71f5 | 2015-06-24 15:52:24 -0700 | [diff] [blame] | 243 | if (!BuildDefs::dump()) |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 244 | return; |
Jim Stichnoth | abce6e5 | 2014-10-14 11:09:27 -0700 | [diff] [blame] | 245 | int NumDigits = 0; |
| 246 | do { |
| 247 | ++NumDigits; |
| 248 | MaxVal /= 10; |
| 249 | } while (MaxVal); |
| 250 | snprintf(Buf, BufLen, "[%%%dlu] ", NumDigits); |
| 251 | } |
| 252 | |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 253 | } // end of anonymous namespace |
| 254 | |
Jim Stichnoth | 8363a06 | 2014-10-07 10:02:38 -0700 | [diff] [blame] | 255 | void TimerStack::dump(Ostream &Str, bool DumpCumulative) { |
Jim Stichnoth | 20b71f5 | 2015-06-24 15:52:24 -0700 | [diff] [blame] | 256 | if (!BuildDefs::dump()) |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 257 | return; |
Jim Stichnoth | abce6e5 | 2014-10-14 11:09:27 -0700 | [diff] [blame] | 258 | const bool UpdateCounts = true; |
| 259 | update(UpdateCounts); |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 260 | double TotalTime = LastTimestamp - FirstTimestamp; |
| 261 | assert(TotalTime); |
Jim Stichnoth | abce6e5 | 2014-10-14 11:09:27 -0700 | [diff] [blame] | 262 | char FmtString[30], PrefixStr[30]; |
Jim Stichnoth | 8363a06 | 2014-10-07 10:02:38 -0700 | [diff] [blame] | 263 | if (DumpCumulative) { |
| 264 | Str << Name << " - Cumulative times:\n"; |
Jim Stichnoth | abce6e5 | 2014-10-14 11:09:27 -0700 | [diff] [blame] | 265 | size_t MaxInternalCount = 0; |
| 266 | for (TimerTreeNode &Node : Nodes) |
| 267 | MaxInternalCount = std::max(MaxInternalCount, Node.UpdateCount); |
| 268 | makePrintfFormatString(FmtString, llvm::array_lengthof(FmtString), |
| 269 | MaxInternalCount); |
| 270 | |
Jim Stichnoth | 8363a06 | 2014-10-07 10:02:38 -0700 | [diff] [blame] | 271 | DumpMapType CumulativeMap; |
| 272 | for (TTindex i = 1; i < Nodes.size(); ++i) { |
| 273 | TTindex Prefix = i; |
| 274 | IceString Suffix = ""; |
| 275 | while (Prefix) { |
| 276 | if (Suffix.empty()) |
| 277 | Suffix = IDs[Nodes[Prefix].Interior]; |
| 278 | else |
| 279 | Suffix = IDs[Nodes[Prefix].Interior] + "." + Suffix; |
| 280 | assert(Nodes[Prefix].Parent < Prefix); |
| 281 | Prefix = Nodes[Prefix].Parent; |
| 282 | } |
Jim Stichnoth | abce6e5 | 2014-10-14 11:09:27 -0700 | [diff] [blame] | 283 | snprintf(PrefixStr, llvm::array_lengthof(PrefixStr), FmtString, |
| 284 | Nodes[i].UpdateCount); |
| 285 | CumulativeMap.insert(std::make_pair(Nodes[i].Time, PrefixStr + Suffix)); |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 286 | } |
Jim Stichnoth | 8363a06 | 2014-10-07 10:02:38 -0700 | [diff] [blame] | 287 | dumpHelper(Str, CumulativeMap, TotalTime); |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 288 | } |
Jim Stichnoth | 8363a06 | 2014-10-07 10:02:38 -0700 | [diff] [blame] | 289 | Str << Name << " - Flat times:\n"; |
Jim Stichnoth | abce6e5 | 2014-10-14 11:09:27 -0700 | [diff] [blame] | 290 | size_t MaxLeafCount = 0; |
| 291 | for (size_t Count : LeafCounts) |
| 292 | MaxLeafCount = std::max(MaxLeafCount, Count); |
| 293 | makePrintfFormatString(FmtString, llvm::array_lengthof(FmtString), |
| 294 | MaxLeafCount); |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 295 | DumpMapType FlatMap; |
| 296 | for (TimerIdT i = 0; i < LeafTimes.size(); ++i) { |
Jim Stichnoth | abce6e5 | 2014-10-14 11:09:27 -0700 | [diff] [blame] | 297 | if (LeafCounts[i]) { |
| 298 | snprintf(PrefixStr, llvm::array_lengthof(PrefixStr), FmtString, |
| 299 | LeafCounts[i]); |
| 300 | FlatMap.insert(std::make_pair(LeafTimes[i], PrefixStr + IDs[i])); |
| 301 | } |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 302 | } |
| 303 | dumpHelper(Str, FlatMap, TotalTime); |
| 304 | Str << "Number of timer updates: " << StateChangeCount << "\n"; |
| 305 | } |
| 306 | |
Jim Stichnoth | 9c234e2 | 2014-10-01 09:28:21 -0700 | [diff] [blame] | 307 | double TimerStack::timestamp() { |
| 308 | // TODO: Implement in terms of std::chrono for C++11. |
| 309 | return llvm::TimeRecord::getCurrentTime(false).getWallTime(); |
| 310 | } |
| 311 | |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 312 | } // end of namespace Ice |