From 23adcf0a239c215b4bb57d3720957e2b1b3c6838 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 15 Oct 2018 16:51:05 -0700 Subject: [PATCH] cli: allow disabling memory/cpu sources This allows us to add new data collection automatically, but allow users to disable it if they know it's unnecessary for their use-case. --- tools/sysprof-cli.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/sysprof-cli.c b/tools/sysprof-cli.c index 3be1b9e9..835a1b24 100644 --- a/tools/sysprof-cli.c +++ b/tools/sysprof-cli.c @@ -88,7 +88,8 @@ main (gint argc, GError *error = NULL; GSource *gsource; gchar *command = NULL; - gboolean memory = FALSE; + gboolean no_memory = FALSE; + gboolean no_cpu = FALSE; gboolean version = FALSE; gboolean force = FALSE; int pid = -1; @@ -98,7 +99,8 @@ main (gint argc, { "pid", 'p', 0, G_OPTION_ARG_INT, &pid, N_("Make sysprof specific to a task"), N_("PID") }, { "command", 'c', 0, G_OPTION_ARG_STRING, &command, N_("Run a command and profile the process"), N_("COMMAND") }, { "force", 'f', 0, G_OPTION_ARG_NONE, &force, N_("Force overwrite the capture file") }, - { "memory", 'm', 0, G_OPTION_ARG_NONE, &memory, N_("Record basic memory statistics") }, + { "no-cpu", 0, 0, G_OPTION_ARG_NONE, &no_cpu, N_("Disable recording of cpu statistics") }, + { "no-memory", 0, 0, G_OPTION_ARG_NONE, &no_memory, N_("Disable recording of memory statistics") }, { "version", 0, 0, G_OPTION_ARG_NONE, &version, N_("Print the sysprof-cli version and exit") }, { NULL } }; @@ -211,11 +213,14 @@ main (gint argc, sp_profiler_add_source (profiler, source); g_object_unref (source); - source = sp_hostinfo_source_new (); - sp_profiler_add_source (profiler, source); - g_object_unref (source); + if (!no_cpu) + { + source = sp_hostinfo_source_new (); + sp_profiler_add_source (profiler, source); + g_object_unref (source); + } - if (memory) + if (!no_memory) { source = sp_memory_source_new (); sp_profiler_add_source (profiler, source);