diff options
author | Dan Gohman <gohman@apple.com> | 2010-06-18 15:56:31 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-06-18 15:56:31 +0000 |
commit | 03c3dc7b6828d48a9f3be50896b3390a696caa64 (patch) | |
tree | fd34a907e926493b458a8d905ab6048dcbc4ad95 /lib/Support | |
parent | 27445f0375ae01652c08569c7843bddc95cedd61 (diff) |
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
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/Timer.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index 784b77cf59..44ee1777cb 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -236,11 +236,13 @@ static Timer &getNamedRegionTimer(StringRef Name) { return T; } -NamedRegionTimer::NamedRegionTimer(StringRef Name) - : TimeRegion(getNamedRegionTimer(Name)) {} +NamedRegionTimer::NamedRegionTimer(StringRef Name, + bool Enabled) + : TimeRegion(!Enabled ? 0 : &getNamedRegionTimer(Name)) {} -NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef GroupName) - : TimeRegion(NamedGroupedTimers->get(Name, GroupName)) {} +NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef GroupName, + bool Enabled) + : TimeRegion(!Enabled ? 0 : &NamedGroupedTimers->get(Name, GroupName)) {} //===----------------------------------------------------------------------===// // TimerGroup Implementation |