>From 7153c42d55d14ad6d367f4e7f8a5482cb814e810 Mon Sep 17 00:00:00 2001 From: Vasilij Schneidermann Date: Sun, 13 Dec 2015 23:09:12 +0100 Subject: [PATCH] Disable profiler log reset on stop --- lisp/profiler.el | 31 +++++++++++++++---------------- src/profiler.c | 16 +--------------- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/lisp/profiler.el b/lisp/profiler.el index f28bbfe..90a4241 100644 --- a/lisp/profiler.el +++ b/lisp/profiler.el @@ -216,19 +216,17 @@ Optional argument MODE means only check for the specified mode (cpu or mem)." (defun profiler-cpu-profile () "Return CPU profile." - (when (profiler-running-p 'cpu) - (profiler-make-profile - :type 'cpu - :timestamp (current-time) - :log (profiler-cpu-log)))) + (profiler-make-profile + :type 'cpu + :timestamp (current-time) + :log (profiler-cpu-log))) (defun profiler-memory-profile () "Return memory profile." - (when (profiler-memory-running-p) - (profiler-make-profile - :type 'memory - :timestamp (current-time) - :log (profiler-memory-log)))) + (profiler-make-profile + :type 'memory + :timestamp (current-time) + :log (profiler-memory-log))) ;;; Calltrees @@ -845,20 +843,21 @@ Also, if MODE is `mem' or `cpu+mem', then memory profiler will be started." t) (defun profiler-report-cpu () + (when (profiler-cpu-log)) (let ((profile (profiler-cpu-profile))) - (when profile - (profiler-report-profile-other-window profile)))) + (profiler-report-profile-other-window profile))) (defun profiler-report-memory () (let ((profile (profiler-memory-profile))) - (when profile - (profiler-report-profile-other-window profile)))) + (profiler-report-profile-other-window profile))) (defun profiler-report () "Report profiling results." (interactive) - (profiler-report-cpu) - (profiler-report-memory)) + (when (and (fboundp 'profiler-cpu-log) (profiler-cpu-log)) + (profiler-report-cpu)) + (when (profiler-memory-log) + (profiler-report-memory))) ;;;###autoload (defun profiler-find-profile (filename) diff --git a/src/profiler.c b/src/profiler.c index efdb1d9..4cd6bb0 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -41,9 +41,7 @@ static Lisp_Object make_log (EMACS_INT heap_size, EMACS_INT max_stack_depth) { /* We use a standard Elisp hash-table object, but we use it in - a special way. This is OK as long as the object is not exposed - to Elisp, i.e. until it is returned by *-profiler-log, after which - it can't be used any more. */ + a special way. */ Lisp_Object log = make_hash_table (hashtest_profiler, make_number (heap_size), make_float (DEFAULT_REHASH_SIZE), @@ -412,12 +410,6 @@ Before returning, a new log is allocated for future samples. */) (void) { Lisp_Object result = cpu_log; - /* Here we're making the log visible to Elisp, so it's not safe any - more for our use afterwards since we can't rely on its special - pre-allocated keys anymore. So we have to allocate a new one. */ - cpu_log = (profiler_cpu_running - ? make_log (profiler_log_size, profiler_max_stack_depth) - : Qnil); Fputhash (Fmake_vector (make_number (1), Qautomatic_gc), make_number (cpu_gc_count), result); @@ -487,12 +479,6 @@ Before returning, a new log is allocated for future samples. */) (void) { Lisp_Object result = memory_log; - /* Here we're making the log visible to Elisp , so it's not safe any - more for our use afterwards since we can't rely on its special - pre-allocated keys anymore. So we have to allocate a new one. */ - memory_log = (profiler_memory_running - ? make_log (profiler_log_size, profiler_max_stack_depth) - : Qnil); return result; } -- 2.6.2