Give NamedRegionTimer an Enabled flag, allowing all its clients to

switch from this:

  if (TimePassesIsEnabled) {
    NamedRegionTimer T(Name, GroupName);
    do_something();
  } else {
    do_something(); // duplicate the code, this time without a timer!
  }

to this:

  {
    NamedRegionTimer T(Name, GroupName, TimePassesIsEnabled);
    do_something();
  }


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106285 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2010-06-18 15:56:31 +00:00
parent 27445f0375
commit 03c3dc7b68
5 changed files with 57 additions and 103 deletions

View File

@@ -150,8 +150,10 @@ public:
/// is primarily used for debugging and for hunting performance problems.
///
struct NamedRegionTimer : public TimeRegion {
explicit NamedRegionTimer(StringRef Name);
explicit NamedRegionTimer(StringRef Name, StringRef GroupName);
explicit NamedRegionTimer(StringRef Name,
bool Enabled = true);
explicit NamedRegionTimer(StringRef Name, StringRef GroupName,
bool Enabled = true);
};