From 01699e2ae35826dc3d16ef6c828c721144443fdd Mon Sep 17 00:00:00 2001 From: "willchan@chromium.org" Date: Wed, 11 Nov 2009 19:24:24 +0000 Subject: linux: TCMalloc-based C++ heap profiler. Requires compiling with linux_use_tcmalloc=1. When enabled by --heap-profiler flag in test_shell exposes chromium.HeapProfiler object to JavaScript. The object has three methods: o start() -- starts profiling o dump() -- dumps data accumulated since start() to file named like chromium-YYYY-MM-DD-TS.heap o stop() -- stops profiling. Output can be analyzed by third_party/tcmalloc/tcmalloc/src/pprof. For example: $ third_party/tcmalloc/tcmalloc/src/pprof \ sconsbuild/Release/test_shell \ chromium-2009-11-06-1234567890.heap See http://code.google.com/p/google-perftools/ for details on how to use pprof. Patch contributed by vitalyr@chromium.org. Original review at http://codereview.chromium.org/377010/show. TBR=vitalyr Review URL: http://codereview.chromium.org/390015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31688 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/tools/test_shell/test_shell_main.cc | 6 ++++++ webkit/tools/test_shell/test_shell_switches.cc | 3 +++ webkit/tools/test_shell/test_shell_switches.h | 1 + 3 files changed, 10 insertions(+) (limited to 'webkit/tools/test_shell') diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc index b069b2f..ea2d625 100644 --- a/webkit/tools/test_shell/test_shell_main.cc +++ b/webkit/tools/test_shell/test_shell_main.cc @@ -29,6 +29,7 @@ #include "webkit/glue/webkit_glue.h" #include "webkit/glue/window_open_disposition.h" #include "webkit/extensions/v8/gc_extension.h" +#include "webkit/extensions/v8/heap_profiler_extension.h" #include "webkit/extensions/v8/playback_extension.h" #include "webkit/extensions/v8/profiler_extension.h" #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" @@ -225,6 +226,11 @@ int main(int argc, char* argv[]) { extensions_v8::ProfilerExtension::Get()); } + if (parsed_command_line.HasSwitch(test_shell::kHeapProfiler)) { + WebScriptController::registerExtension( + extensions_v8::HeapProfilerExtension::Get()); + } + // Load and initialize the stats table. Attempt to construct a somewhat // unique name to isolate separate instances from each other. StatsTable *table = new StatsTable( diff --git a/webkit/tools/test_shell/test_shell_switches.cc b/webkit/tools/test_shell/test_shell_switches.cc index 1142ee1..d0bf04c 100644 --- a/webkit/tools/test_shell/test_shell_switches.cc +++ b/webkit/tools/test_shell/test_shell_switches.cc @@ -82,4 +82,7 @@ extern const char kGDB[] = "gdb"; // Make functions of the Profiler class available in javascript extern const char kProfiler[] = "profiler"; +// Make functions of the HeapProfiler class available in javascript +extern const char kHeapProfiler[] = "heap-profiler"; + } // namespace test_shell diff --git a/webkit/tools/test_shell/test_shell_switches.h b/webkit/tools/test_shell/test_shell_switches.h index d580695..0330e0a 100644 --- a/webkit/tools/test_shell/test_shell_switches.h +++ b/webkit/tools/test_shell/test_shell_switches.h @@ -33,6 +33,7 @@ extern const char kAllowScriptsToCloseWindows[]; extern const char kCheckLayoutTestSystemDeps[]; extern const char kGDB[]; extern const char kProfiler[]; +extern const char kHeapProfiler[]; } // namespace test_shell -- cgit v1.1