[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gcl-devel] generic function performance
From: |
Peter Wood |
Subject: |
[Gcl-devel] generic function performance |
Date: |
Sat, 4 Jan 2003 12:42:58 +0100 |
User-agent: |
Mutt/1.4i |
Hi
In another post, I showed how we can make some functions (like typep,
subtypep and coerce) be generic, using #'pcl::make-specializable. It
is really a big advantage to be able to use this technique since we
can automatically reuse the present code, with small modifications,
and build some fancy-ansi stuff on top. However, I suggested that it
might have negative performance implications.
Well I've been doing some informal testing, and I'm not sure that the
performance impact is very significant.
> (symbol-function 'typep)
#<compiled-closure #:SPECIALIZED-TYPEP>
> (time (typep 'foo 'symbol))
real time : 0.000 secs
run time : 0.000 secs
T
> (symbol-function 'subtypep)
#<compiled-closure #:SPECIALIZED-SUBTYPEP>
> (time (subtypep 'symbol 't))
real time : 0.000 secs
run time : 0.000 secs
T
T
> (defclass foo ()())
#<Standard-Class FOO 1041116550>
> (defclass bar (foo)())
#<Standard-Class BAR 1041062404>
> (subtypep (find-class 'bar) (find-class 'foo))
(#<Standard-Class FOO 1041116550>
#<Standard-Class STANDARD-OBJECT 1030554554>
#<Slot-Class PCL::SLOT-OBJECT 1030553344>
#<Built-In-Class T 1030553264>)
T
; the first value is true (a generalized boolean ie, not nil).
> (time (subtypep (find-class 'bar) (find-class 'foo)))
real time : 0.000 secs
run time : 0.000 secs
(#<Standard-Class FOO 1041116550>
#<Standard-Class STANDARD-OBJECT 1030554554>
#<Slot-Class PCL::SLOT-OBJECT 1030553344>
#<Built-In-Class T 1030553264>)
T
> (setf f1 (make-instance 'foo))
#<FOO 1041011700>
> (time (typep f1 (find-class 'foo)))
real time : 0.000 secs
run time : 0.000 secs
#<FOO 1041011700>
It looks ok to me.
Whaddya think?
Regards,
Peter
- [Gcl-devel] generic function performance,
Peter Wood <=