(in-package #:sb-sprof) (let ((samples (samples-vector *samples*)) (counts (make-hash-table :test #'equal))) (with-lookup-tables () (loop :for start = 0 :then end :while (< start (length samples)) :for end = (or (position 'trace-start samples :start (1+ start)) (return)) :do (let ((key (with-output-to-string (stream) (loop :for i :from (- end 2) :downto (+ start 2) :by 2 :for node = (lookup-node (aref samples i)) :when node :do (let ((*print-pretty* nil)) (format stream "~A;" (node-name node))))))) (incf (gethash key counts 0))))) (with-open-file (stream "/tmp/counts.txt" :direction :output :if-does-not-exist :create :if-exists :supersede) (maphash (lambda (trace count) (format stream "~A ~D~%" trace count)) counts)) (sb-ext:run-program "/home/jmoringe/data/FlameGraph/flamegraph.pl" '("/tmp/counts.txt") :output "/tmp/graph.svg" :if-output-exists :supersede))