[gjs: 4/11] profiler: Disable profiler in interactive mode
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 4/11] profiler: Disable profiler in interactive mode
- Date: Thu, 25 Jan 2018 01:22:33 +0000 (UTC)
commit dc7feb1115b52d48460df79956963126e919edb7
Author: Philip Chimento <philip endlessm com>
Date: Thu Jan 18 14:18:38 2018 -0800
profiler: Disable profiler in interactive mode
It doesn't make sense to run the profiler while we're spending most of
the time waiting for command input anyway.
gjs/console.cpp | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/gjs/console.cpp b/gjs/console.cpp
index 7ba11f2..5b1b634 100644
--- a/gjs/console.cpp
+++ b/gjs/console.cpp
@@ -36,7 +36,7 @@ static char *coverage_output_path = NULL;
static char *profile_output_path = nullptr;
static char *command = NULL;
static gboolean print_version = false;
-static gboolean enable_profiler = false;
+static bool enable_profiler = false;
static gboolean parse_profile_arg(const char *, const char *, void *, GError **);
@@ -193,7 +193,7 @@ main(int argc, char **argv)
GError *error = NULL;
GjsContext *js_context;
GjsCoverage *coverage = NULL;
- GjsProfiler *profiler;
+ GjsProfiler *profiler = nullptr;
char *script;
const char *filename;
const char *program_name;
@@ -204,6 +204,7 @@ main(int argc, char **argv)
char * const *script_argv;
const char *env_coverage_output_path;
const char *env_coverage_prefixes;
+ bool interactive_mode = false;
setlocale(LC_ALL, "");
@@ -267,6 +268,7 @@ main(int argc, char **argv)
len = strlen(script);
filename = "<stdin>";
program_name = gjs_argv[0];
+ interactive_mode = true;
} else {
/* All unprocessed options should be in script_argv */
g_assert(gjs_argc == 2);
@@ -313,17 +315,21 @@ main(int argc, char **argv)
if (env_profiler)
enable_profiler = true;
- profiler = gjs_profiler_new(js_context);
+ if (interactive_mode && enable_profiler) {
+ g_message("Profiler disabled in interactive mode.");
+ } else if (!interactive_mode) {
+ profiler = gjs_profiler_new(js_context);
- /* Allow SIGUSR2 (with sigaction param) to enable/disable */
- gjs_profiler_setup_signals();
+ /* Allow SIGUSR2 (with sigaction param) to enable/disable */
+ gjs_profiler_setup_signals();
- if (enable_profiler) {
- if (profile_output_path) {
- gjs_profiler_set_filename(profiler, profile_output_path);
- g_free(profile_output_path);
+ if (enable_profiler) {
+ if (profile_output_path) {
+ gjs_profiler_set_filename(profiler, profile_output_path);
+ g_free(profile_output_path);
+ }
+ gjs_profiler_start(profiler);
}
- gjs_profiler_start(profiler);
}
/* prepare command line arguments */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]