Paste number 319875: profiling experiment

Paste number 319875: profiling experiment
Pasted by: rme
When:11 months, 3 weeks ago
Share:Tweet this! |
Paste contents:
Raw Source | XML | Display As
(in-package :ccl)

(defun sample-process-loop (process hash)
    (map-call-frames (lambda (p context)
                       (declare (ignore context))
                       (incf (gethash (cfp-lfun p) hash 0)))
                     :process process
                     :count 1)
    (sleep 0.001)))

(defun report-samples (h)
  (let ((results (make-array (hash-table-count h) :adjustable t
                             :fill-pointer 0)))
    (maphash (lambda (k v)
               (vector-push-extend (cons k v) results))
    (setq results (sort results #'> :key 'cdr))
    (dotimes (i (length results))
      (let ((item (aref results i)))
        (format t "~&~5d  ~s" (cdr item) (car item))))))

(defun call-with-sampling (fn)
  (let* ((h (make-hash-table))
         (sampling-process (process-run-function "sampler"
         (funcall fn)
      (process-kill sampling-process))

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.