diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-25 23:10:34 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-25 23:10:34 +0000 |
commit | ed0fd001fda34d17c109d0a7b1a07181ce48006b (patch) | |
tree | 11891fc7f2775089dc8833296598ae1b1054c191 /base | |
parent | 82c91e04bdfa264c9292eb398fa5fbbcf17abf7d (diff) | |
download | chromium_src-ed0fd001fda34d17c109d0a7b1a07181ce48006b.zip chromium_src-ed0fd001fda34d17c109d0a7b1a07181ce48006b.tar.gz chromium_src-ed0fd001fda34d17c109d0a7b1a07181ce48006b.tar.bz2 |
[UMA] Add performance profile data to UMA uploads.
BUG=103480
TEST=unit_test --gtest_filter=MetricsLogTest.*
TBR=jar@chromium.org
(Re-commit of [ https://chromiumcodereview.appspot.com/9702015/ ])
Review URL: http://codereview.chromium.org/10224010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134006 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/profiler/alternate_timer.cc | 15 | ||||
-rw-r--r-- | base/profiler/alternate_timer.h | 21 | ||||
-rw-r--r-- | base/tracked_objects.cc | 18 |
3 files changed, 23 insertions, 31 deletions
diff --git a/base/profiler/alternate_timer.cc b/base/profiler/alternate_timer.cc index 05a983c..abf9180 100644 --- a/base/profiler/alternate_timer.cc +++ b/base/profiler/alternate_timer.cc @@ -6,20 +6,25 @@ #include "base/logging.h" -namespace tracked_objects { +namespace { + +tracked_objects::NowFunction* g_time_function = NULL; -static NowFunction* g_time_function = NULL; +} // anonymous namespace + +namespace tracked_objects { const char kAlternateProfilerTime[] = "CHROME_PROFILER_TIME"; // Set an alternate timer function to replace the OS time function when // profiling. void SetAlternateTimeSource(NowFunction* now_function) { - DCHECK_EQ(g_time_function, reinterpret_cast<NowFunction*>(NULL)); + DCHECK_EQ(reinterpret_cast<NowFunction*>(NULL), g_time_function); g_time_function = now_function; } -extern NowFunction* GetAlternateTimeSource() { +NowFunction* GetAlternateTimeSource() { return g_time_function; } -} // tracked_objects + +} // namespace tracked_objects diff --git a/base/profiler/alternate_timer.h b/base/profiler/alternate_timer.h index 883b24f..778dc62 100644 --- a/base/profiler/alternate_timer.h +++ b/base/profiler/alternate_timer.h @@ -5,32 +5,31 @@ // This is a glue file, which allows third party code to call into our profiler // without having to include most any functions from base. - #ifndef BASE_PROFILER_ALTERNATE_TIMER_H_ #define BASE_PROFILER_ALTERNATE_TIMER_H_ +#include "base/base_export.h" + namespace tracked_objects { // Provide type for an alternate timer function. typedef unsigned int NowFunction(); +// Environment variable name that is used to activate alternate timer profiling +// (such as using TCMalloc allocations to provide a pseudo-timer) for tasks +// instead of wall clock profiling. +extern const char kAlternateProfilerTime[]; + // Set an alternate timer function to replace the OS time function when // profiling. Typically this is called by an allocator that is providing a // function that indicates how much memory has been allocated on any given // thread. -extern void SetAlternateTimeSource(NowFunction* now_function); +void SetAlternateTimeSource(NowFunction* now_function); // Gets the pointer to a function that was set via SetAlternateTimeSource(). // Returns NULL if no set was done prior to calling GetAlternateTimeSource. -extern NowFunction* GetAlternateTimeSource(); - -// Environment variable name that is used to activate alternate timer profiling -// (such as using TCMalloc allocations to provide a pseudo-timer) for tasks -// instead of wall clock profiling. -extern const char kAlternateProfilerTime[]; - - +BASE_EXPORT NowFunction* GetAlternateTimeSource(); -} // tracked_objects +} // namespace tracked_objects #endif // BASE_PROFILER_ALTERNATE_TIMER_H_ diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc index fe3f712..ae508c4 100644 --- a/base/tracked_objects.cc +++ b/base/tracked_objects.cc @@ -648,21 +648,9 @@ void ThreadData::Reset() { } static void OptionallyInitializeAlternateTimer() { - char* alternate_selector = getenv(kAlternateProfilerTime); - if (!alternate_selector) - return; - switch (*alternate_selector) { - case '0': // This is the default value, and uses the wall clock time. - break; - case '1': { - // Use the TCMalloc allocations-on-thread as a pseudo-time. - ThreadData::SetAlternateTimeSource(GetAlternateTimeSource()); - break; - } - default: - NOTREACHED(); - break; - } + NowFunction* alternate_time_source = GetAlternateTimeSource(); + if (alternate_time_source) + ThreadData::SetAlternateTimeSource(alternate_time_source); } bool ThreadData::Initialize() { |