From: bradb
Subject: Profiling all functions in SBCL
Date: 
Message-ID: <1128699097.581877.100620@f14g2000cwb.googlegroups.com>
Hi, I am using SBCL and would like to profile my app.  SBCL offers
(sb-profile:profile name), where name must be a plain string
representation of a function name.  I also think that "profile" is a
macro.
How can I profile all my functions?  I suspect that I want to loop with
do-symbols or something similar, then check if the symbol is a function
and if it is call profile.
But I can't quite get there.  Any tips please?

Brad

From: Pascal Bourguignon
Subject: Re: Profiling all functions in SBCL
Date: 
Message-ID: <87slvdz34p.fsf@thalassa.informatimago.com>
"bradb" <··············@gmail.com> writes:

> Hi, I am using SBCL and would like to profile my app.  SBCL offers
> (sb-profile:profile name), where name must be a plain string
> representation of a function name.  I also think that "profile" is a
> macro.
> How can I profile all my functions?  I suspect that I want to loop with
> do-symbols or something similar, then check if the symbol is a function
> and if it is call profile.
> But I can't quite get there.  Any tips please?

So you cannot write a lisp expression and you want to profile some?
Perhaps you should learn lisp before trying to optimize it don't you think?

(do-symbols (s *package*)
   (when (fboundp s) (sb-profile:profile (symbol-name s))))


That said, I doubt that name must be a plain string.  It must probably
be a symbol, and if sb-profile:profile is indeed a macro then you can
either write is as:

(do-symbols (s *package*)
   (when (fboundp s) (eval `(sb-profile:profile ,s))))


or find out what actual function is called by the macro, and write:

* (macroexpand-1  '(sb-profile:profile name))

(SB-PROFILE::MAPC-ON-NAMED-FUNS (FUNCTION SB-PROFILE::PROFILE-1-FUN) (QUOTE (NAME)))

So you can write it directly as:

(SB-PROFILE::MAPC-ON-NAMED-FUNS
   (FUNCTION SB-PROFILE::PROFILE-1-FUN)
   (let ((functions '())
      (do-symbols (s *package*) (when (fboundp s) (push s functions))))))



I'd bet that if you read more the documentation (or the sources) of
sb-profile, you'd find a function that does exactly this:

(SB-PROFILE::MAPC-ON-NAMED-FUNS
   (FUNCTION SB-PROFILE::PROFILE-1-FUN) functions)


-- 
"This machine is a piece of GAGH!  I need dual Opteron 850
processors if I am to do battle with this code!"
From: bradb
Subject: Re: Profiling all functions in SBCL
Date: 
Message-ID: <1128705156.664598.243270@g49g2000cwa.googlegroups.com>
> So you cannot write a lisp expression and you want to profile some?
> Perhaps you should learn lisp before trying to optimize it don't you think?
I am learning Lisp right now, by reading documents (like
http://www.sbcl.org/manual/Accurate-Profiler.html#Accurate%20Profiler)
and asking questions here.  Thanks for taking the time to answer my
question - I now know a little more.
Also, to answer your question - I am not actually wanting to optimise
yet, I am wanting to profile.  I think it will be an important part of
me learning Lisp to get an idea for how much functions cons - hence the
need to profile.  This situation arose because I was using CMUCL to
write an ncurses app, but GC was kicking in a lot.  Profiling showed
that each alien call consed ~37K, and a few keypresses were consing
over 32MB in 2 repeatedly called functions.
Compiling those functions resulted in no consing.  So I decided to move
to SBCL because it is compiled.  Since I still had profiling on my mind
I wanted to see how much SBCL consed.  Hence my question, which
googling did not turn up an answer for.

Thanks
Brad
From: GP lisper
Subject: Re: Profiling all functions in SBCL
Date: 
Message-ID: <1128740590.1beaa730471a19fa75cdacfa5c8f98f8@teranews>
On Fri, 07 Oct 2005 18:46:30 +0200, <····@mouse-potato.com> wrote:
> "bradb" <··············@gmail.com> writes:
>
>> But I can't quite get there.  Any tips please?
>
> So you cannot write a lisp expression and you want to profile some?
> Perhaps you should learn lisp before trying to optimize it don't you think?

This is a hint about the nature of the questioner...note the lack of
any sample code related to the question.

-- 
In Common Lisp quite a few aspects of pathname semantics are left to
the implementation.