How to Use Sprof

How to profile a dynamically linked library without sprof?

The answer was to use valgrind and KCachegrind

Using SBCL's profiler in my own package

You need to evaluate the require before you do the defpackage of your own package. The defpackage won't automatically require the SB-PROF module for you. Think of require as some kind of "fancy" load, which loads the module into the image. During loading, the module's packages get created, and only after that are you able to reference them from within a defpackage or via the reader (sb-sprof:with-profiling).

Often, when I am too lazy to do it right (or if it's a "one-shot" solution), I use a small "loadup.lisp" script, which makes sure, that all my dependencies are present and then loads up my own code. This also makes sure, that the image can reliably be reproduced from in a fresh lisp.

Something along the lines of

;; Make sure, the dependencies are present

(ql:quickload '(whatever)) ;; Load a dependency via Quicklisp
(require :sb-something-else) ;; ... or via some implementation-dependent repository
(asdf:oos 'asdf:load-op 'some-module) ;; ... or via ASDF or ... or ... or ...

;; Now, load my own stuff

(load "packages")
(load "something-important-1")
...

The order of these operations is important; you cannot reference any packages from dependency modules in your own package declarations, before those modules have been properly loaded.



Related Topics



Leave a reply



Submit