Subject: bug#21765: 24.5; Profiler innefective for recursive functions

From: Jonathan H <[email-masked]>
Date: Mon, 26 Oct 2015 10:47:01 -0700

The Emacs profiler cannot be used to effectively profile, because the
reports do not flatten the recursion.

Take for example, this recipie:

;; Naive Fibonacci has terrible time complexity.
(defun fib (n)
  (if (< n 3)
      1
    (+ (fib (- n 1))
       (fib (- n 2)))))

(profiler-start 'cpu)
(fib 30)
(profiler-report)
(profiler-stop)

Here, The profiler report assigns (nearly) all of the time to (+ ...),
including time from deeper invocations of fib (and their invocations of (+
...), which makes the profiling report less-than-optimal.

Thanks,
PythonNut