diff --git a/engine/src/flutter/tools/debugger/prompt/BUILD.gn b/engine/src/flutter/tools/debugger/prompt/BUILD.gn index 59848f19e9c..18dfc95497b 100644 --- a/engine/src/flutter/tools/debugger/prompt/BUILD.gn +++ b/engine/src/flutter/tools/debugger/prompt/BUILD.gn @@ -15,6 +15,7 @@ mojo_native_application("prompt") { deps = [ "//base", + "//base/allocator", "//mojo/application", "//mojo/common", "//mojo/public/cpp/bindings", diff --git a/engine/src/flutter/tools/debugger/prompt/prompt.cc b/engine/src/flutter/tools/debugger/prompt/prompt.cc index 1c7154eb84b..0432d09f9df 100644 --- a/engine/src/flutter/tools/debugger/prompt/prompt.cc +++ b/engine/src/flutter/tools/debugger/prompt/prompt.cc @@ -5,7 +5,7 @@ #include #include "base/bind.h" -#include "base/files/file_path.h" +#include "base/debug/profiler.h" #include "base/memory/weak_ptr.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" @@ -91,6 +91,10 @@ class Prompt : public mojo::ApplicationDelegate, Quit(connection_id); else if (info.path == "/load") Load(connection_id, info.data); + else if (info.path == "/start_profiling") + StartProfiling(connection_id); + else if (info.path == "/stop_profiling") + StopProfiling(connection_id); else { Help(info.path, connection_id); } @@ -172,6 +176,16 @@ class Prompt : public mojo::ApplicationDelegate, Respond(connection_id, trace); } + void StartProfiling(int connection_id) { + base::debug::StartProfiling("sky_viewer.pprof"); + Respond(connection_id, "Starting profiling (type 'stop_profiling' to stop"); + } + + void StopProfiling(int connection_id) { + base::debug::StopProfiling(); + Respond(connection_id, "Stopped profiling"); + } + bool is_tracing_; DebuggerPtr debugger_; tracing::TraceCoordinatorPtr tracing_; diff --git a/engine/src/flutter/tools/skydb b/engine/src/flutter/tools/skydb index 38db95efa17..abdbbd4094b 100755 --- a/engine/src/flutter/tools/skydb +++ b/engine/src/flutter/tools/skydb @@ -387,6 +387,10 @@ class SkyDebugger(object): 'reload the current page') self._add_basic_command(subparsers, 'inspect', '/inspect', 'stop the running sky instance') + self._add_basic_command(subparsers, 'start_profiling', '/start_profiling', + 'starts profiling the running sky instance (Linux only)') + self._add_basic_command(subparsers, 'stop_profiling', '/stop_profiling', + 'stios profiling the running sky instance (Linux only)') load_parser = subparsers.add_parser('load', help='load a new page in the currently running sky')