summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2012-09-26 00:02:21 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2012-09-26 00:02:21 -0400
commit234148bf943ffce55121aefc8694889eb08b0daa (patch)
tree452f66cfbbc026717c86835bac900f74018093dd
parent611b7507a8eb63d0c3fd8b5c6182920453292688 (diff)
downloademacs-old-branches/profiler.tar.gz
* lisp/profiler.el (profiler-start): Don't prompt for choice when thereold-branches/profiler
isn't any. (profiler-stop): Use new semantics of profiler-*-stop. (profiler-reset, profiler--report-cpu): Don't signal an error if the cpu profiler is not available. * src/profiler.c (Fprofiler_cpu_stop, Fprofiler_memory_stop): Return whether the profiler was running, instead of signaling an error if it wasn't.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/profiler.el33
-rw-r--r--src/ChangeLog10
-rw-r--r--src/profiler.c21
4 files changed, 42 insertions, 30 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 64fb7e2ffc7..d7304b68ade 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2012-09-26 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * profiler.el (profiler-start): Don't prompt for choice when there
+ isn't any.
+ (profiler-stop): Use new semantics of profiler-*-stop.
+ (profiler-reset, profiler--report-cpu): Don't signal an error if the
+ cpu profiler is not available.
+
2012-09-24 Stefan Monnier <monnier@iro.umontreal.ca>
* profiler.el (profiler-sample-interval): Move before first use.
diff --git a/lisp/profiler.el b/lisp/profiler.el
index fb38b00c2d8..91bd744fb35 100644
--- a/lisp/profiler.el
+++ b/lisp/profiler.el
@@ -574,9 +574,10 @@ MODE can be one of `cpu', `mem', or `cpu+mem'.
If MODE is `cpu' or `cpu+mem', time-based profiler will be started.
Also, if MODE is `mem' or `cpu+mem', then memory profiler will be started."
(interactive
- (list (intern (completing-read "Mode (default cpu): "
- '("cpu" "mem" "cpu+mem")
- nil t nil nil "cpu"))))
+ (list (if (not (fboundp 'profiler-cpu-start)) 'mem
+ (intern (completing-read "Mode (default cpu): "
+ '("cpu" "mem" "cpu+mem")
+ nil t nil nil "cpu")))))
(cl-ecase mode
(cpu
(profiler-cpu-start profiler-sample-interval)
@@ -592,30 +593,24 @@ Also, if MODE is `mem' or `cpu+mem', then memory profiler will be started."
(defun profiler-stop ()
"Stop started profilers. Profiler logs will be kept."
(interactive)
- (cond
- ((and (profiler-cpu-running-p)
- (profiler-memory-running-p))
- (profiler-cpu-stop)
- (profiler-memory-stop)
- (message "CPU and memory profiler stopped"))
- ((profiler-cpu-running-p)
- (profiler-cpu-stop)
- (message "CPU profiler stopped"))
- ((profiler-memory-running-p)
- (profiler-memory-stop)
- (message "Memory profiler stopped"))
- (t
- (error "No profilers started"))))
+ (let ((cpu (if (fboundp 'profiler-cpu-stop) (profiler-cpu-stop)))
+ (mem (profiler-memory-stop)))
+ (message "%s profiler stopped"
+ (cond ((and mem cpu) "CPU and memory")
+ (mem "Memory")
+ (cpu "CPU")
+ (t "No")))))
(defun profiler-reset ()
"Reset profiler log."
(interactive)
- (ignore (profiler-cpu-log))
+ (when (fboundp 'profiler-cpu-log)
+ (ignore (profiler-cpu-log)))
(ignore (profiler-memory-log))
t)
(defun profiler--report-cpu ()
- (let ((log (profiler-cpu-log)))
+ (let ((log (if (fboundp 'profiler-cpu-log) (profiler-cpu-log))))
(when log
(puthash 'type 'cpu log)
(puthash 'timestamp (current-time) log)
diff --git a/src/ChangeLog b/src/ChangeLog
index f540aef3814..ce6f56fa8fc 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2012-09-26 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * profiler.c (Fprofiler_cpu_stop, Fprofiler_memory_stop):
+ Return whether the profiler was running, instead of signaling an error
+ if it wasn't.
+
2012-09-26 Juanma Barranquero <lekktu@gmail.com>
* makefile.w32-in (OBJ2, GLOBAL_SOURCES): Add profiler.c.
@@ -106,8 +112,8 @@
* w32uniscribe.c (uniscribe_shape): Fix producing gstring
components for RTL text (Bug#11860). Adjust X-OFFSET of each
non-base glyph for the width of the base character, according to
- what x_draw_composite_glyph_string_foreground expects. Generate
- WADJUST value according to composition_gstring_width's
+ what x_draw_composite_glyph_string_foreground expects.
+ Generate WADJUST value according to composition_gstring_width's
expectations, to produce correct width of the composed character.
Reverse the sign of the DU offset produced by ScriptPlace.
diff --git a/src/profiler.c b/src/profiler.c
index 8573d13b554..e7593a6a0e0 100644
--- a/src/profiler.c
+++ b/src/profiler.c
@@ -257,19 +257,20 @@ See also `profiler-log-size' and `profiler-max-stack-depth'. */)
timer.it_value = timer.it_interval;
setitimer (ITIMER_PROF, &timer, 0);
- profiler_cpu_running = 1;
+ profiler_cpu_running = true;
return Qt;
}
DEFUN ("profiler-cpu-stop", Fprofiler_cpu_stop, Sprofiler_cpu_stop,
0, 0, 0,
- doc: /* Stop the cpu profiler. The profiler log is not affected. */)
+ doc: /* Stop the cpu profiler. The profiler log is not affected.
+Return non-nil if the profiler was running. */)
(void)
{
if (!profiler_cpu_running)
- error ("Sample profiler is not running");
- profiler_cpu_running = 0;
+ return Qnil;
+ profiler_cpu_running = false;
setitimer (ITIMER_PROF, 0, 0);
@@ -332,7 +333,7 @@ See also `profiler-log-size' and `profiler-max-stack-depth'. */)
memory_log = make_log (profiler_log_size,
profiler_max_stack_depth);
- profiler_memory_running = 1;
+ profiler_memory_running = true;
return Qt;
}
@@ -340,13 +341,13 @@ See also `profiler-log-size' and `profiler-max-stack-depth'. */)
DEFUN ("profiler-memory-stop",
Fprofiler_memory_stop, Sprofiler_memory_stop,
0, 0, 0,
- doc: /* Stop the memory profiler. The profiler log is not affected. */)
+ doc: /* Stop the memory profiler. The profiler log is not affected.
+Return non-nil if the profiler was running. */)
(void)
{
if (!profiler_memory_running)
- error ("Memory profiler is not running");
- profiler_memory_running = 0;
-
+ return Qnil;
+ profiler_memory_running = false;
return Qt;
}
@@ -403,6 +404,7 @@ to make room for new entries. */);
profiler_log_size = 10000;
#ifdef PROFILER_CPU_SUPPORT
+ profiler_cpu_running = false;
cpu_log = Qnil;
staticpro (&cpu_log);
defsubr (&Sprofiler_cpu_start);
@@ -410,6 +412,7 @@ to make room for new entries. */);
defsubr (&Sprofiler_cpu_running_p);
defsubr (&Sprofiler_cpu_log);
#endif
+ profiler_memory_running = false;
memory_log = Qnil;
staticpro (&memory_log);
defsubr (&Sprofiler_memory_start);