diff options
| author | Tomohiro Matsuyama | 2012-10-01 07:21:25 +0900 |
|---|---|---|
| committer | Tomohiro Matsuyama | 2012-10-01 07:21:25 +0900 |
| commit | c22bac2cc59c6c04924ecf62c5eeb97a92df7e28 (patch) | |
| tree | 707758235e762854e17742bbbcc737687b85e457 /src | |
| parent | 5e4daaf3face7ed54de7cb3621edb31e16b011ed (diff) | |
| download | emacs-c22bac2cc59c6c04924ecf62c5eeb97a92df7e28.tar.gz emacs-c22bac2cc59c6c04924ecf62c5eeb97a92df7e28.zip | |
* profiler.el (profiler-sampling-interval): Rename from
profiler-sample-interval.
(profiler-sampling-interval): Default to 10.
(profiler-find-profile): New command (was profiler-find-log).
(profiler-find-profile-other-window): New command.
(profiler-find-profile-other-frame): New command.
(profiler-profile): Introduce API-level data structure.
Diffstat (limited to 'src')
| -rw-r--r-- | src/profiler.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/profiler.c b/src/profiler.c index de118d13859..2f082edc390 100644 --- a/src/profiler.c +++ b/src/profiler.c | |||
| @@ -198,7 +198,7 @@ record_backtrace (log_t *log, EMACS_INT count) | |||
| 198 | } | 198 | } |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | /* Sample profiler. */ | 201 | /* Sampling profiler. */ |
| 202 | 202 | ||
| 203 | #ifdef PROFILER_CPU_SUPPORT | 203 | #ifdef PROFILER_CPU_SUPPORT |
| 204 | 204 | ||
| @@ -220,10 +220,10 @@ static Lisp_Object cpu_log; | |||
| 220 | /* Separate counter for the time spent in the GC. */ | 220 | /* Separate counter for the time spent in the GC. */ |
| 221 | static EMACS_INT cpu_gc_count; | 221 | static EMACS_INT cpu_gc_count; |
| 222 | 222 | ||
| 223 | /* The current sample interval in milliseconds. */ | 223 | /* The current sampling interval in milliseconds. */ |
| 224 | static EMACS_INT current_sample_interval; | 224 | static EMACS_INT current_sampling_interval; |
| 225 | 225 | ||
| 226 | /* Signal handler for sample profiler. */ | 226 | /* Signal handler for sampling profiler. */ |
| 227 | 227 | ||
| 228 | static void | 228 | static void |
| 229 | handle_profiler_signal (int signal) | 229 | handle_profiler_signal (int signal) |
| @@ -235,11 +235,11 @@ handle_profiler_signal (int signal) | |||
| 235 | not expect the ARRAY_MARK_FLAG to be set. We could try and | 235 | not expect the ARRAY_MARK_FLAG to be set. We could try and |
| 236 | harden the hash-table code, but it doesn't seem worth the | 236 | harden the hash-table code, but it doesn't seem worth the |
| 237 | effort. */ | 237 | effort. */ |
| 238 | cpu_gc_count = saturated_add (cpu_gc_count, current_sample_interval); | 238 | cpu_gc_count = saturated_add (cpu_gc_count, current_sampling_interval); |
| 239 | else | 239 | else |
| 240 | { | 240 | { |
| 241 | eassert (HASH_TABLE_P (cpu_log)); | 241 | eassert (HASH_TABLE_P (cpu_log)); |
| 242 | record_backtrace (XHASH_TABLE (cpu_log), current_sample_interval); | 242 | record_backtrace (XHASH_TABLE (cpu_log), current_sampling_interval); |
| 243 | } | 243 | } |
| 244 | } | 244 | } |
| 245 | 245 | ||
| @@ -250,21 +250,21 @@ deliver_profiler_signal (int signal) | |||
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | static enum profiler_cpu_running | 252 | static enum profiler_cpu_running |
| 253 | setup_cpu_timer (Lisp_Object sample_interval) | 253 | setup_cpu_timer (Lisp_Object sampling_interval) |
| 254 | { | 254 | { |
| 255 | struct sigaction action; | 255 | struct sigaction action; |
| 256 | struct itimerval timer; | 256 | struct itimerval timer; |
| 257 | struct timespec interval; | 257 | struct timespec interval; |
| 258 | 258 | ||
| 259 | if (! RANGED_INTEGERP (1, sample_interval, | 259 | if (! RANGED_INTEGERP (1, sampling_interval, |
| 260 | (TYPE_MAXIMUM (time_t) < EMACS_INT_MAX / 1000 | 260 | (TYPE_MAXIMUM (time_t) < EMACS_INT_MAX / 1000 |
| 261 | ? (EMACS_INT) TYPE_MAXIMUM (time_t) * 1000 + 999 | 261 | ? (EMACS_INT) TYPE_MAXIMUM (time_t) * 1000 + 999 |
| 262 | : EMACS_INT_MAX))) | 262 | : EMACS_INT_MAX))) |
| 263 | return NOT_RUNNING; | 263 | return NOT_RUNNING; |
| 264 | 264 | ||
| 265 | current_sample_interval = XINT (sample_interval); | 265 | current_sampling_interval = XINT (sampling_interval); |
| 266 | interval = make_emacs_time (current_sample_interval / 1000, | 266 | interval = make_emacs_time (current_sampling_interval / 1000, |
| 267 | current_sample_interval % 1000 * 1000000); | 267 | current_sampling_interval % 1000 * 1000000); |
| 268 | emacs_sigaction_init (&action, deliver_profiler_signal); | 268 | emacs_sigaction_init (&action, deliver_profiler_signal); |
| 269 | sigaction (SIGPROF, &action, 0); | 269 | sigaction (SIGPROF, &action, 0); |
| 270 | 270 | ||
| @@ -315,12 +315,12 @@ setup_cpu_timer (Lisp_Object sample_interval) | |||
| 315 | DEFUN ("profiler-cpu-start", Fprofiler_cpu_start, Sprofiler_cpu_start, | 315 | DEFUN ("profiler-cpu-start", Fprofiler_cpu_start, Sprofiler_cpu_start, |
| 316 | 1, 1, 0, | 316 | 1, 1, 0, |
| 317 | doc: /* Start or restart the cpu profiler. | 317 | doc: /* Start or restart the cpu profiler. |
| 318 | It takes call-stack samples each SAMPLE-INTERVAL milliseconds. | 318 | It takes call-stack samples each SAMPLING-INTERVAL milliseconds. |
| 319 | See also `profiler-log-size' and `profiler-max-stack-depth'. */) | 319 | See also `profiler-log-size' and `profiler-max-stack-depth'. */) |
| 320 | (Lisp_Object sample_interval) | 320 | (Lisp_Object sampling_interval) |
| 321 | { | 321 | { |
| 322 | if (profiler_cpu_running) | 322 | if (profiler_cpu_running) |
| 323 | error ("Sample profiler is already running"); | 323 | error ("CPU profiler is already running"); |
| 324 | 324 | ||
| 325 | if (NILP (cpu_log)) | 325 | if (NILP (cpu_log)) |
| 326 | { | 326 | { |
| @@ -329,9 +329,9 @@ See also `profiler-log-size' and `profiler-max-stack-depth'. */) | |||
| 329 | profiler_max_stack_depth); | 329 | profiler_max_stack_depth); |
| 330 | } | 330 | } |
| 331 | 331 | ||
| 332 | profiler_cpu_running = setup_cpu_timer (sample_interval); | 332 | profiler_cpu_running = setup_cpu_timer (sampling_interval); |
| 333 | if (! profiler_cpu_running) | 333 | if (! profiler_cpu_running) |
| 334 | error ("Invalid sample interval"); | 334 | error ("Invalid sampling interval"); |
| 335 | 335 | ||
| 336 | return Qt; | 336 | return Qt; |
| 337 | } | 337 | } |