[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

carwash PCL/Flavors comparison



I converted Mike Thome's version of the carwash demo into Flavors.
Here are some timing results:

      8/28  12/7
CARS  PCL   PCL       Flavors  pcl/flavors
 20  .715   .659       .291      2.26
 50  2.24  2.19        .934      2.34
100  7.36  7.24       4.17       1.76

Notes:
0.  These times were the median of the last 3 of 4 times generated using:
(progn (generate-cars N)
       (scl:without-interrupts
         (dotimes (i 4)
	   (time (get-going)))))

1.  Here, newest PCL is faster than the old one by about 8 - 10%!

2.  Here, Flavors is about 2.3 times faster than PCL.  My conversion
relys on dispatch only being done on the first argument, although some
PCL methods are defined on 2 arguments.  This demo only tests method
and accessor use, which is reasonable, but not the only things to compare.

3.  The carwash has a distinct N squared behavior, so for large N the
PCL/Flavors performance is less important.  Rewriting the simulation
to use queues rather than nconcing lists, should reduce this.

4.  This are the machine parameters:
Symbolics System, FEP1:>enhanced-pci-from-pci.load.1
3640 Processor, 1536K words Physical memory, 21250K words Swapping space.
 Genera                                             7.2
BBN Rhythm & Blues 

5.  Here is the flavor conversion code:
;;; Just enough to get carwash converted to FLAVORS.
(in-package 'car :use '(lisp))

(shadowing-import '(flavor::self) 'car)
(import '(flavor::make-instance) 'car)

(defmacro defclass (name supers slots)
  `(flavor::defflavor ,name
	   ,(map 'list #'(lambda (s) (list (first s) (getf (cdr s) :initform))) slots)
	   ,supers
     (:conc-name nil)
     :writable-instance-variables
     :readable-instance-variables
     :initable-instance-variables))

(defmacro defmethod (name args &body body)
  (let ((class (second (first args)))
	(me (first (first args))))
    (setq args (map 'list #'(lambda (a) (if (consp a) (first a) a)) (cdr args)))
    `(flavor::defmethod (,name ,class) ,args 
       (let ((,me self))
	 ,@body))))