Commit 234148bf authored by Stefan Monnier's avatar Stefan Monnier

* lisp/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.
* src/profiler.c (Fprofiler_cpu_stop, Fprofiler_memory_stop):
Return whether the profiler was running, instead of signaling an error
if it wasn't.
parent 611b7507
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.
......
......@@ -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)
......
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.
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment