[gambit-list] Profiling of expanded code?

Guillaume Cartier gcartier at jazzscheme.org
Thu Nov 6 09:19:43 EST 2008


For statprof to work with your code, you will have to rewrite your macros
using Gambit's ##define-syntax.

When you use define-macro, Gambit strips all source information before
passing the sexpr to expand to your macro. With ##define-syntax, you will
receive a source object containing source positioning information for every
sexpr in the form to expand. You can then insert those source objects into
the expansion of your macro. Doing that, every Gambit tool that needs source
information like statprof will now work with your macros.

Here's a 'when' macro defined using ##define-syntax :

(##define-syntax when
  (lambda (form-src)
    (let ((test (cadr (##source-code form-src)))
          (body (cddr (##source-code form-src))))
      (##sourcify
        `(if ,test
             (begin
               , at body)
           #f)
        form-src))))

A partial list of primitives you will need :

   - (##source? expr) : guess what it does :)
   - (##source-code source) : returns the sepxr that was sourcified by
   'source'
   - (##desourcify source) : full recursive desourcification of 'source'
   - (##sourcify expr source) : creates a source object for 'expr' that has
   the same source info as 'source'


On Thu, Nov 6, 2008 at 8:21 AM, David St-Hilaire
<sthilaid at iro.umontreal.ca>wrote:

> Hi all!
>
> I often use Guillaume Germain's profiler for gambit
> (http://www.iro.umontreal.ca/~germaing/statprof.html) and I would like to
> know
> if its possible to get a profiling result on the marco expanded code, and
> not
> the source code.
>
> I ask this because I wrote several macro which define multiple functions.
> It
> seems that lots of the work is done within these functions but the profiler
> only
> tells me that it is my macro call who does all the work (but its in fact
> the
> code generated by that macro). So having access to a profiling report of
> the
> macro expanded code could be usefull :)
>
> Thanks!
>
> David
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20081106/6b648880/attachment.htm>


More information about the Gambit-list mailing list