aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2012-09-26 00:02:21 -0400
committerStefan Monnier2012-09-26 00:02:21 -0400
commit234148bf943ffce55121aefc8694889eb08b0daa (patch)
tree452f66cfbbc026717c86835bac900f74018093dd
parent611b7507a8eb63d0c3fd8b5c6182920453292688 (diff)
downloademacs-234148bf943ffce55121aefc8694889eb08b0daa.tar.gz
emacs-234148bf943ffce55121aefc8694889eb08b0daa.zip
* 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 @@
12012-09-26 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * profiler.el (profiler-start): Don't prompt for choice when there
4 isn't any.
5 (profiler-stop): Use new semantics of profiler-*-stop.
6 (profiler-reset, profiler--report-cpu): Don't signal an error if the
7 cpu profiler is not available.
8
12012-09-24 Stefan Monnier <monnier@iro.umontreal.ca> 92012-09-24 Stefan Monnier <monnier@iro.umontreal.ca>
2 10
3 * profiler.el (profiler-sample-interval): Move before first use. 11 * 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'.
574If MODE is `cpu' or `cpu+mem', time-based profiler will be started. 574If MODE is `cpu' or `cpu+mem', time-based profiler will be started.
575Also, if MODE is `mem' or `cpu+mem', then memory profiler will be started." 575Also, if MODE is `mem' or `cpu+mem', then memory profiler will be started."
576 (interactive 576 (interactive
577 (list (intern (completing-read "Mode (default cpu): " 577 (list (if (not (fboundp 'profiler-cpu-start)) 'mem
578 '("cpu" "mem" "cpu+mem") 578 (intern (completing-read "Mode (default cpu): "
579 nil t nil nil "cpu")))) 579 '("cpu" "mem" "cpu+mem")
580 nil t nil nil "cpu")))))
580 (cl-ecase mode 581 (cl-ecase mode
581 (cpu 582 (cpu
582 (profiler-cpu-start profiler-sample-interval) 583 (profiler-cpu-start profiler-sample-interval)
@@ -592,30 +593,24 @@ Also, if MODE is `mem' or `cpu+mem', then memory profiler will be started."
592(defun profiler-stop () 593(defun profiler-stop ()
593 "Stop started profilers. Profiler logs will be kept." 594 "Stop started profilers. Profiler logs will be kept."
594 (interactive) 595 (interactive)
595 (cond 596 (let ((cpu (if (fboundp 'profiler-cpu-stop) (profiler-cpu-stop)))
596 ((and (profiler-cpu-running-p) 597 (mem (profiler-memory-stop)))
597 (profiler-memory-running-p)) 598 (message "%s profiler stopped"
598 (profiler-cpu-stop) 599 (cond ((and mem cpu) "CPU and memory")
599 (profiler-memory-stop) 600 (mem "Memory")
600 (message "CPU and memory profiler stopped")) 601 (cpu "CPU")
601 ((profiler-cpu-running-p) 602 (t "No")))))
602 (profiler-cpu-stop)
603 (message "CPU profiler stopped"))
604 ((profiler-memory-running-p)
605 (profiler-memory-stop)
606 (message "Memory profiler stopped"))
607 (t
608 (error "No profilers started"))))
609 603
610(defun profiler-reset () 604(defun profiler-reset ()
611 "Reset profiler log." 605 "Reset profiler log."
612 (interactive) 606 (interactive)
613 (ignore (profiler-cpu-log)) 607 (when (fboundp 'profiler-cpu-log)
608 (ignore (profiler-cpu-log)))
614 (ignore (profiler-memory-log)) 609 (ignore (profiler-memory-log))
615 t) 610 t)
616 611
617(defun profiler--report-cpu () 612(defun profiler--report-cpu ()
618 (let ((log (profiler-cpu-log))) 613 (let ((log (if (fboundp 'profiler-cpu-log) (profiler-cpu-log))))
619 (when log 614 (when log
620 (puthash 'type 'cpu log) 615 (puthash 'type 'cpu log)
621 (puthash 'timestamp (current-time) log) 616 (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 @@
12012-09-26 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * profiler.c (Fprofiler_cpu_stop, Fprofiler_memory_stop):
4 Return whether the profiler was running, instead of signaling an error
5 if it wasn't.
6
12012-09-26 Juanma Barranquero <lekktu@gmail.com> 72012-09-26 Juanma Barranquero <lekktu@gmail.com>
2 8
3 * makefile.w32-in (OBJ2, GLOBAL_SOURCES): Add profiler.c. 9 * makefile.w32-in (OBJ2, GLOBAL_SOURCES): Add profiler.c.
@@ -106,8 +112,8 @@
106 * w32uniscribe.c (uniscribe_shape): Fix producing gstring 112 * w32uniscribe.c (uniscribe_shape): Fix producing gstring
107 components for RTL text (Bug#11860). Adjust X-OFFSET of each 113 components for RTL text (Bug#11860). Adjust X-OFFSET of each
108 non-base glyph for the width of the base character, according to 114 non-base glyph for the width of the base character, according to
109 what x_draw_composite_glyph_string_foreground expects. Generate 115 what x_draw_composite_glyph_string_foreground expects.
110 WADJUST value according to composition_gstring_width's 116 Generate WADJUST value according to composition_gstring_width's
111 expectations, to produce correct width of the composed character. 117 expectations, to produce correct width of the composed character.
112 Reverse the sign of the DU offset produced by ScriptPlace. 118 Reverse the sign of the DU offset produced by ScriptPlace.
113 119
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'. */)
257 timer.it_value = timer.it_interval; 257 timer.it_value = timer.it_interval;
258 setitimer (ITIMER_PROF, &timer, 0); 258 setitimer (ITIMER_PROF, &timer, 0);
259 259
260 profiler_cpu_running = 1; 260 profiler_cpu_running = true;
261 261
262 return Qt; 262 return Qt;
263} 263}
264 264
265DEFUN ("profiler-cpu-stop", Fprofiler_cpu_stop, Sprofiler_cpu_stop, 265DEFUN ("profiler-cpu-stop", Fprofiler_cpu_stop, Sprofiler_cpu_stop,
266 0, 0, 0, 266 0, 0, 0,
267 doc: /* Stop the cpu profiler. The profiler log is not affected. */) 267 doc: /* Stop the cpu profiler. The profiler log is not affected.
268Return non-nil if the profiler was running. */)
268 (void) 269 (void)
269{ 270{
270 if (!profiler_cpu_running) 271 if (!profiler_cpu_running)
271 error ("Sample profiler is not running"); 272 return Qnil;
272 profiler_cpu_running = 0; 273 profiler_cpu_running = false;
273 274
274 setitimer (ITIMER_PROF, 0, 0); 275 setitimer (ITIMER_PROF, 0, 0);
275 276
@@ -332,7 +333,7 @@ See also `profiler-log-size' and `profiler-max-stack-depth'. */)
332 memory_log = make_log (profiler_log_size, 333 memory_log = make_log (profiler_log_size,
333 profiler_max_stack_depth); 334 profiler_max_stack_depth);
334 335
335 profiler_memory_running = 1; 336 profiler_memory_running = true;
336 337
337 return Qt; 338 return Qt;
338} 339}
@@ -340,13 +341,13 @@ See also `profiler-log-size' and `profiler-max-stack-depth'. */)
340DEFUN ("profiler-memory-stop", 341DEFUN ("profiler-memory-stop",
341 Fprofiler_memory_stop, Sprofiler_memory_stop, 342 Fprofiler_memory_stop, Sprofiler_memory_stop,
342 0, 0, 0, 343 0, 0, 0,
343 doc: /* Stop the memory profiler. The profiler log is not affected. */) 344 doc: /* Stop the memory profiler. The profiler log is not affected.
345Return non-nil if the profiler was running. */)
344 (void) 346 (void)
345{ 347{
346 if (!profiler_memory_running) 348 if (!profiler_memory_running)
347 error ("Memory profiler is not running"); 349 return Qnil;
348 profiler_memory_running = 0; 350 profiler_memory_running = false;
349
350 return Qt; 351 return Qt;
351} 352}
352 353
@@ -403,6 +404,7 @@ to make room for new entries. */);
403 profiler_log_size = 10000; 404 profiler_log_size = 10000;
404 405
405#ifdef PROFILER_CPU_SUPPORT 406#ifdef PROFILER_CPU_SUPPORT
407 profiler_cpu_running = false;
406 cpu_log = Qnil; 408 cpu_log = Qnil;
407 staticpro (&cpu_log); 409 staticpro (&cpu_log);
408 defsubr (&Sprofiler_cpu_start); 410 defsubr (&Sprofiler_cpu_start);
@@ -410,6 +412,7 @@ to make room for new entries. */);
410 defsubr (&Sprofiler_cpu_running_p); 412 defsubr (&Sprofiler_cpu_running_p);
411 defsubr (&Sprofiler_cpu_log); 413 defsubr (&Sprofiler_cpu_log);
412#endif 414#endif
415 profiler_memory_running = false;
413 memory_log = Qnil; 416 memory_log = Qnil;
414 staticpro (&memory_log); 417 staticpro (&memory_log);
415 defsubr (&Sprofiler_memory_start); 418 defsubr (&Sprofiler_memory_start);