diff options
-rw-r--r-- | base/profiler.cc | 14 | ||||
-rw-r--r-- | base/profiler.h | 3 | ||||
-rw-r--r-- | webkit/extensions/v8/profiler_extension.cc | 13 |
3 files changed, 30 insertions, 0 deletions
diff --git a/base/profiler.cc b/base/profiler.cc index cff16a5..1f28a73 100644 --- a/base/profiler.cc +++ b/base/profiler.cc @@ -5,6 +5,10 @@ #include "base/profiler.h" #include "base/string_util.h" +#if defined(USE_TCMALLOC) +#include "third_party/tcmalloc/chromium/src/google/profiler.h" +#endif + // When actually using quantify, uncomment the following line. // #define QUANTIFY @@ -20,12 +24,22 @@ namespace base { void Profiler::StartRecording() { #ifdef QUANTIFY QuantifyStartRecordingData(); +#elif defined(USE_TCMALLOC) && defined(OS_LINUX) + ProfilerStart("chrome-profile"); #endif } void Profiler::StopRecording() { #ifdef QUANTIFY QuantifyStopRecordingData(); +#elif defined(USE_TCMALLOC) && defined(OS_LINUX) + ProfilerStop(); +#endif +} + +void Profiler::Flush() { +#if defined(USE_TCMALLOC) && defined(OS_LINUX) + ProfilerFlush(); #endif } diff --git a/base/profiler.h b/base/profiler.h index 8a6cce8..4fd1117 100644 --- a/base/profiler.h +++ b/base/profiler.h @@ -26,6 +26,9 @@ class Profiler { // time in application startup. static void ClearData(); + // Flushes all recorded data to disk. No-op until recording is started. + static void Flush(); + // Sets the name of the current thread for display in the profiler's UI. static void SetThreadName(const char *name); diff --git a/webkit/extensions/v8/profiler_extension.cc b/webkit/extensions/v8/profiler_extension.cc index 7a4f13f..cbfc721 100644 --- a/webkit/extensions/v8/profiler_extension.cc +++ b/webkit/extensions/v8/profiler_extension.cc @@ -21,6 +21,7 @@ class ProfilerWrapper : public v8::Extension { "chromium.Profiler = function() {" " native function ProfilerStart();" " native function ProfilerStop();" + " native function ProfilerFlush();" " native function ProfilerClearData();" " native function ProfilerSetThreadName();" " this.start = function() {" @@ -32,6 +33,9 @@ class ProfilerWrapper : public v8::Extension { " this.clear = function() {" " ProfilerClearData();" " };" + " this.flush = function() {" + " ProfilerFlush();" + " };" " this.setThreadName = function(name) {" " ProfilerSetThreadName(name);" " };" @@ -45,6 +49,8 @@ class ProfilerWrapper : public v8::Extension { return v8::FunctionTemplate::New(ProfilerStop); } else if (name->Equals(v8::String::New("ProfilerClearData"))) { return v8::FunctionTemplate::New(ProfilerClearData); + } else if (name->Equals(v8::String::New("ProfilerFlush"))) { + return v8::FunctionTemplate::New(ProfilerFlush); } else if (name->Equals(v8::String::New("ProfilerSetThreadName"))) { return v8::FunctionTemplate::New(ProfilerSetThreadName); } @@ -69,6 +75,13 @@ class ProfilerWrapper : public v8::Extension { return v8::Undefined(); } + static v8::Handle<v8::Value> ProfilerFlush( + const v8::Arguments& args) { + base::Profiler::Flush(); + return v8::Undefined(); + } + + static v8::Handle<v8::Value> ProfilerSetThreadName( const v8::Arguments& args) { if (args.Length() >= 1 && args[0]->IsString()) { |