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

Re: Compilation of methods per class.

I am unable to reproduce quite the results you show.

At the end of this message is some code which is largely based on your
example.  It differs only in the timing macro used, and that it
automates (using PCL internal stuff) the process of restarting from
scratch to `fill the caches' in the other order.

Using this data, I show that for 10000 calls to SLOW-FOO, the best time
(in seconds, on a SUN 4/330, in Lucid 3.0.1) is .13.  Whatever variation
there is doesn't seem to be related to the order in which the `caches
are filled'.  This, of course, ignores the first run of each test after
doing a reset to allow time for the caches to fill.

Could you try this code, or look at this code, to see how it differs
with what you are measuring.


(use-package 'pcl)

(defclass everybody-inherit-class () ())
(defclass class1  (everybody-inherit-class) ())
(defclass class2  (everybody-inherit-class) ())

(defmethod really-fast-foo ((self everybody-inherit-class)) 10)
(defmethod slow-foo        ((self class1)) 31)
(defmethod slow-foo        ((self class2)) 32)

(defvar i1 (make-instance 'class1))
(defvar i2 (make-instance 'class2))

(defun test (x y)
  (let ((i1 (make-instance 'class1))
	(i2 (make-instance 'class2)))
    (setq y (/ y 2))
    (dotimes (i x)
      (dotimes (i y) (slow-foo i1) (slow-foo i2))
      (time (dotimes (i y) (slow-foo i1) (slow-foo i2)))
      (time (dotimes (i y) (slow-foo i1) (slow-foo i2)))
      (dotimes (i y) (slow-foo i1) (slow-foo i2))
      (time (dotimes (i y) (slow-foo i2) (slow-foo i1)))
      (time (dotimes (i y) (slow-foo i2) (slow-foo i1))))))

(defun reset ()
  (pcl::invalidate-discriminating-function #'slow-foo)
  (pcl::invalidate-discriminating-function #'really-fast-foo))