View Single Post
  #7 (permalink)  
Old 09-15-2006, 07:39 AM
jurgen_defurne
Guest
 
Posts: n/a
Default Re: Use of macro's for conditional compilation ?

Thomas F. Burdick wrote:
> tar@sevak.isi.edu (Thomas A. Russ) writes:
>
> > "jurgen_defurne" <jurgen.defurne@pandora.be> writes:
> >
> > > And I know about CLOS and generic functions, but I have tested CLOS,
> > > and while it might certainly have applications in more complex
> > > settings, I want to extract the last drop of performance for my
> > > program. A test program (in SBCL) written to test the access time to a
> > > structure or an object, showed the access time to a structure to be two
> > > times faster than CLOS.

> >
> > To add to your CLOS knowledge, there is nothing that stops you from
> > using generic functions that dispatch on types introduced by DEFSTRUCT.
> > So you can still use the generic function dispatch to decide which
> > function to call at run-time while enjoying the faster access times of
> > structs versus classes. This lets you use Pascal's solution to the
> > problem of run-time dispatch.
> >
> > But the next question is whether you really need the last drop of
> > performance for your program. How much of the TOTAL runtime of the
> > program is spent performing slot accesses? Can you reduce that by using
> > local variables instead? How much of an improvement does subsituting
> > structs for classes make in the final runtime of the program?

>
> These are all good questions, but since the poster is using a specific
> implementation (SBCL) some other questions raise themselves; are you
> losing anything by using structs versus defclass? Although the spec
> doesn't have defined semantics for structure redefinition, SBCL does.
> You still only get single inheritance, and no before/after/around
> methods on accessors, but that may be good enough for a given module.
> Are you storing the types of values in your slots which you want to
> declare? The implementation treats structure slot definitions as
> assertions, and is able to use that information when doing type
> inference elsewhere. A couple of :type (unsigned-byte 7) (vector
> single-float) declarations in defstructs can be really helpful when
> compiling at (speed 3), while keeping your code readable overall.
> This last one is the big win for structures in SBCL, IMNSHO.


By using SBCL and its type system, and after asserting that my test
programs ran correctly, I could get an ultimate speedup of 600%
compared to my initial implementation which did not have any type
declarations.

Regards,

Jurgen

Reply With Quote