summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorvadimt <vadimt@chromium.org>2014-11-06 14:27:43 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-06 22:27:57 +0000
commita156831d7f339c46779ad68f03eaca8f6b433f65 (patch)
tree35ab294daa7242069752c0e57bb9075ef05d10ff /base
parent6c8e7e9125f05406fefe48718c5d251825277277 (diff)
downloadchromium_src-a156831d7f339c46779ad68f03eaca8f6b433f65.zip
chromium_src-a156831d7f339c46779ad68f03eaca8f6b433f65.tar.gz
chromium_src-a156831d7f339c46779ad68f03eaca8f6b433f65.tar.bz2
Enable profiler timing with a field trial.
In Browser process, if profiler timing field trial is "Enabled", enable profiler timing. This is necessary to measure the performance impact of enabling profiler timing on Android, and, perhaps, rolling out profiler timing enabling afterwards. Profiler timing is currently disabled on Android because of performance concerns, but the impact on the standard perf metricts is not yet known, hence this CL. BUG=315070 Review URL: https://codereview.chromium.org/693103005 Cr-Commit-Position: refs/heads/master@{#303100}
Diffstat (limited to 'base')
-rw-r--r--base/tracked_objects.cc37
-rw-r--r--base/tracked_objects.h3
2 files changed, 29 insertions, 11 deletions
diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc
index 4fe88512..c69fada5 100644
--- a/base/tracked_objects.cc
+++ b/base/tracked_objects.cc
@@ -54,18 +54,27 @@ const ThreadData::Status kInitialStartupState =
// problem with its presence).
static const bool kAllowAlternateTimeSourceHandling = true;
+// Possible states of the profiler timing enabledness.
+enum {
+ UNDEFINED_TIMING,
+ ENABLED_TIMING,
+ DISABLED_TIMING,
+};
+
+// State of the profiler timing enabledness.
+base::subtle::Atomic32 g_profiler_timing_enabled = UNDEFINED_TIMING;
+
+// Returns whether profiler timing is enabled. The default is true, but this may
+// be overridden by a command-line flag. Some platforms may programmatically set
+// this command-line flag to the "off" value if it's not specified.
+// This in turn can be overridden by explicitly calling
+// ThreadData::EnableProfilerTiming, say, based on a field trial.
inline bool IsProfilerTimingEnabled() {
- enum {
- UNDEFINED_TIMING,
- ENABLED_TIMING,
- DISABLED_TIMING,
- };
- static base::subtle::Atomic32 timing_enabled = UNDEFINED_TIMING;
- // Reading |timing_enabled| is done without barrier because multiple
- // initialization is not an issue while the barrier can be relatively costly
- // given that this method is sometimes called in a tight loop.
+ // Reading |g_profiler_timing_enabled| is done without barrier because
+ // multiple initialization is not an issue while the barrier can be relatively
+ // costly given that this method is sometimes called in a tight loop.
base::subtle::Atomic32 current_timing_enabled =
- base::subtle::NoBarrier_Load(&timing_enabled);
+ base::subtle::NoBarrier_Load(&g_profiler_timing_enabled);
if (current_timing_enabled == UNDEFINED_TIMING) {
if (!CommandLine::InitializedForCurrentProcess())
return true;
@@ -75,7 +84,8 @@ inline bool IsProfilerTimingEnabled() {
switches::kProfilerTimingDisabledValue)
? DISABLED_TIMING
: ENABLED_TIMING;
- base::subtle::NoBarrier_Store(&timing_enabled, current_timing_enabled);
+ base::subtle::NoBarrier_Store(&g_profiler_timing_enabled,
+ current_timing_enabled);
}
return current_timing_enabled == ENABLED_TIMING;
}
@@ -775,6 +785,11 @@ void ThreadData::SetAlternateTimeSource(NowFunction* now_function) {
}
// static
+void ThreadData::EnableProfilerTiming() {
+ base::subtle::NoBarrier_Store(&g_profiler_timing_enabled, ENABLED_TIMING);
+}
+
+// static
TrackedTime ThreadData::Now() {
if (kAllowAlternateTimeSourceHandling && now_function_)
return TrackedTime::FromMilliseconds((*now_function_)());
diff --git a/base/tracked_objects.h b/base/tracked_objects.h
index 222f581..50bea47 100644
--- a/base/tracked_objects.h
+++ b/base/tracked_objects.h
@@ -466,6 +466,9 @@ class BASE_EXPORT ThreadData {
// relationships can be (optionally) calculated.
static void PrepareForStartOfRun(const Births* parent);
+ // Enables profiler timing.
+ static void EnableProfilerTiming();
+
// Provide a time function that does nothing (runs fast) when we don't have
// the profiler enabled. It will generally be optimized away when it is
// ifdef'ed to be small enough (allowing the profiler to be "compiled out" of