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

Unified Diff: src/IceGlobalContext.cpp

Issue 620373004: Subzero: Add a few performance measurement tools. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Improve the use of containers Created 6 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceGlobalContext.h ('k') | src/IceInstX8632.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceGlobalContext.cpp
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp
index 7ea7e5dd02d10eaa64310926fb54b3cc9d3d4efc..80728b090a84efca3f6a77b7ca164814b6f9e7af 100644
--- a/src/IceGlobalContext.cpp
+++ b/src/IceGlobalContext.cpp
@@ -119,7 +119,11 @@ GlobalContext::GlobalContext(llvm::raw_ostream *OsDump,
: StrDump(OsDump), StrEmit(OsEmit), VMask(Mask),
ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt),
TestPrefix(TestPrefix), Flags(Flags), HasEmittedFirstMethod(false),
- RNG(""), Timers(new TimerStack("main")) {}
+ RNG("") {
+ // Pre-register built-in stack names.
+ newTimerStackID("Total across all functions");
+ newTimerStackID("Per-function summary");
+}
// Scan a string for S[0-9A-Z]*_ patterns and replace them with
// S<num>_ where <num> is the next base-36 value. If a type name
@@ -381,13 +385,27 @@ ConstantList GlobalContext::getConstantPool(Type Ty) const {
llvm_unreachable("Unknown type");
}
-TimerIdT GlobalContext::getTimerID(const IceString &Name) {
- return TimerStack::getTimerID(Name);
+TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID,
+ const IceString &Name) {
+ assert(StackID < Timers.size());
+ return Timers[StackID].getTimerID(Name);
+}
+
+TimerStackIdT GlobalContext::newTimerStackID(const IceString &Name) {
+ TimerStackIdT NewID = Timers.size();
+ Timers.push_back(TimerStack(Name));
+ return NewID;
}
-void GlobalContext::pushTimer(TimerIdT ID) { Timers->push(ID); }
+void GlobalContext::pushTimer(TimerIdT ID, TimerStackIdT StackID) {
+ assert(StackID < Timers.size());
+ Timers[StackID].push(ID);
+}
-void GlobalContext::popTimer(TimerIdT ID) { Timers->pop(ID); }
+void GlobalContext::popTimer(TimerIdT ID, TimerStackIdT StackID) {
+ assert(StackID < Timers.size());
+ Timers[StackID].pop(ID);
+}
void GlobalContext::dumpStats(const IceString &Name, bool Final) {
if (Flags.DumpStats) {
@@ -400,6 +418,16 @@ void GlobalContext::dumpStats(const IceString &Name, bool Final) {
}
}
-void GlobalContext::dumpTimers() { Timers->dump(getStrDump()); }
+void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) {
+ assert(Timers.size() > StackID);
+ Timers[StackID].dump(getStrDump(), DumpCumulative);
+}
+
+TimerMarker::TimerMarker(TimerIdT ID, const Cfg *Func)
+ : ID(ID), Ctx(Func->getContext()),
+ Active(Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled) {
+ if (Active)
+ Ctx->pushTimer(ID);
+}
} // end of namespace Ice
« no previous file with comments | « src/IceGlobalContext.h ('k') | src/IceInstX8632.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698