The SBCL distribution includes a nice statistical profiler contrib, which is mostly just a straightforward port of Gerd Moellman's work for CMUCL. One of the features that has been added afterwards is integration between the disassembler and the profiler:
[]
; 4C9: WAIT ; 56/1000 samples
; 4CA: FSTD FR5 ; 3/1000 samples
; 4CC: FSTPD FR0 ; 3/1000 samples
; 4CE: FLDD FR4 ; 17/1000 samples
; 4D0: FMULD FR5 ; 4/1000 samples
; 4D2: WAIT ; 31/1000 samples
; 4D3: MOV EAX, [#x9035424] ; -30d0
; 12/1000 samples
; 4D9: FSTPD FR6 ; 1/1000 samples
[]
This was originally intended to be a cute but completely useless hack, but unfortunately it has actually been of some use every now and then. Here's a second attempt at "cute but useless"; annotation of source code with profiling information:
CL-USER> (sb-sprof::profile-annotate-source #'find-zero-with-test-2*)
(§<b>[8/1000</b>§
(LAMBDA ()
(SB-INT:NAMED-LAMBDA FIND-ZERO-WITH-TEST-2* (XK-1 XK EPSILON)
(DECLARE (TYPE DOUBLE-FLOAT XK-1 XK EPSILON)
(OPTIMIZE (SPEED 2) (DEBUG 2)))
(BLOCK FIND-ZERO-WITH-TEST-2*
(§<b>[23/1000]</b>§
(LABELS ((TEST-2 (X)
(DECLARE (DOUBLE-FLOAT X))
(§<b>[23/1000]</b>§ (+ (§<b>[126/1000]</b>§ (* X X)) -3)))
(NEXT-X-1 (F XK-1 XK)
(DECLARE (DOUBLE-FLOAT XK-1 XK) (IGNORE F))
(§<b>[2/1000]</b>§ (/ (§<b>[78/1000]</b>§ (+ XK-1 XK)) 20d0)))
(FIND-ZERO (F NEXT-X XK-1 XK EPSILON)
(§<b>[83/1000]</b>§
(LABELS ((FIND-ZERO-RECURSIVE (XK-1 XK)
(§<b>[4/1000]</b>§
(LET ((XK+1
(§<b>[30/1000]</b>§ (FUNCALL NEXT-X F XK-1 XK))))
(IF
(<
(§<b>[184/1000]</b>§
(ABS (§<b>[48/1000]</b>§ (FUNCALL F XK+1))))
EPSILON)
XK+1
(IF
(§<b>[36/1000]</b>§
(<
(§<b>[18/1000]</b>§
(* (§<b>[26/1000]</b>§ (FUNCALL F XK))
(§<b>[12/1000]</b>§ (FUNCALL F XK+1))))
00d0))
(FIND-ZERO-RECURSIVE XK XK+1)
(§<b>[29/1000]</b>§
(FIND-ZERO-RECURSIVE XK-1 XK+1))))))))
(FIND-ZERO-RECURSIVE XK-1 XK)))))
(DECLARE (INLINE TEST-2 NEXT-X-1 FIND-ZERO))
(FIND-ZERO #'TEST-2 #'NEXT-X-1 XK-1 XK EPSILON)))))))
As a bonus, the implementation is a really disgusting hack.