Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(405)

Side by Side Diff: src/IceTimerTree.cpp

Issue 686913005: Turn off dump/emit routines when building minimal subzero. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 Node.UpdateCount = 0; 120 Node.UpdateCount = 0;
121 } 121 }
122 } 122 }
123 123
124 namespace { 124 namespace {
125 125
126 typedef std::multimap<double, IceString> DumpMapType; 126 typedef std::multimap<double, IceString> DumpMapType;
127 127
128 // Dump the Map items in reverse order of their time contribution. 128 // Dump the Map items in reverse order of their time contribution.
129 void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) { 129 void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) {
130 if (!ALLOW_DUMP)
131 return;
130 // TODO(stichnot): Use llvm::make_range with LLVM 3.5. 132 // TODO(stichnot): Use llvm::make_range with LLVM 3.5.
131 for (auto I = Map.rbegin(), E = Map.rend(); I != E; ++I) { 133 for (auto I = Map.rbegin(), E = Map.rend(); I != E; ++I) {
132 char buf[80]; 134 char buf[80];
133 snprintf(buf, llvm::array_lengthof(buf), " %10.6f (%4.1f%%): ", I->first, 135 snprintf(buf, llvm::array_lengthof(buf), " %10.6f (%4.1f%%): ", I->first,
134 I->first * 100 / TotalTime); 136 I->first * 100 / TotalTime);
135 Str << buf << I->second << "\n"; 137 Str << buf << I->second << "\n";
136 } 138 }
137 } 139 }
138 140
139 // Write a printf() format string into Buf[], in the format "[%5lu] ", 141 // Write a printf() format string into Buf[], in the format "[%5lu] ",
140 // where "5" is actually the number of digits in MaxVal. E.g., 142 // where "5" is actually the number of digits in MaxVal. E.g.,
141 // MaxVal=0 ==> "[%1lu] " 143 // MaxVal=0 ==> "[%1lu] "
142 // MaxVal=5 ==> "[%1lu] " 144 // MaxVal=5 ==> "[%1lu] "
143 // MaxVal=9876 ==> "[%4lu] " 145 // MaxVal=9876 ==> "[%4lu] "
144 void makePrintfFormatString(char *Buf, size_t BufLen, size_t MaxVal) { 146 void makePrintfFormatString(char *Buf, size_t BufLen, size_t MaxVal) {
147 if (!ALLOW_DUMP)
148 return;
145 int NumDigits = 0; 149 int NumDigits = 0;
146 do { 150 do {
147 ++NumDigits; 151 ++NumDigits;
148 MaxVal /= 10; 152 MaxVal /= 10;
149 } while (MaxVal); 153 } while (MaxVal);
150 snprintf(Buf, BufLen, "[%%%dlu] ", NumDigits); 154 snprintf(Buf, BufLen, "[%%%dlu] ", NumDigits);
151 } 155 }
152 156
153 } // end of anonymous namespace 157 } // end of anonymous namespace
154 158
155 void TimerStack::dump(Ostream &Str, bool DumpCumulative) { 159 void TimerStack::dump(Ostream &Str, bool DumpCumulative) {
160 if (!ALLOW_DUMP)
161 return;
156 const bool UpdateCounts = true; 162 const bool UpdateCounts = true;
157 update(UpdateCounts); 163 update(UpdateCounts);
158 double TotalTime = LastTimestamp - FirstTimestamp; 164 double TotalTime = LastTimestamp - FirstTimestamp;
159 assert(TotalTime); 165 assert(TotalTime);
160 char FmtString[30], PrefixStr[30]; 166 char FmtString[30], PrefixStr[30];
161 if (DumpCumulative) { 167 if (DumpCumulative) {
162 Str << Name << " - Cumulative times:\n"; 168 Str << Name << " - Cumulative times:\n";
163 size_t MaxInternalCount = 0; 169 size_t MaxInternalCount = 0;
164 for (TimerTreeNode &Node : Nodes) 170 for (TimerTreeNode &Node : Nodes)
165 MaxInternalCount = std::max(MaxInternalCount, Node.UpdateCount); 171 MaxInternalCount = std::max(MaxInternalCount, Node.UpdateCount);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 dumpHelper(Str, FlatMap, TotalTime); 207 dumpHelper(Str, FlatMap, TotalTime);
202 Str << "Number of timer updates: " << StateChangeCount << "\n"; 208 Str << "Number of timer updates: " << StateChangeCount << "\n";
203 } 209 }
204 210
205 double TimerStack::timestamp() { 211 double TimerStack::timestamp() {
206 // TODO: Implement in terms of std::chrono for C++11. 212 // TODO: Implement in terms of std::chrono for C++11.
207 return llvm::TimeRecord::getCurrentTime(false).getWallTime(); 213 return llvm::TimeRecord::getCurrentTime(false).getWallTime();
208 } 214 }
209 215
210 } // end of namespace Ice 216 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698