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

Re: Event heartbeat.

At 14:17 2/5/93 -0500, Guillaume Cartier wrote:
>| I seem to be unable to get idle events generated any faster than
>| about 20/second.  I think I've set all the various specials etc.
>| that control this.  Any suggestions?  - ben
>You can call EVENT-DISPATCH explicitly from your code to get
>faster event dispatching. Programs that are purely event driven
>can have toplevel functions like the following, for the fastest
>event dispatching possible:
>  (lambda ()
>    (loop
>      (let ((form (get-next-queued-form)))
>        (when form
>          (eval form)))
>      (event-dispatch))))

It's not quite that simple. Since I noticed that MCL was spending lots
of its time in WINDOW-NULL-EVENT-HANDLER, I added some code that limits
the rate to 60/second. If you want it to happen faster than that, you'll
have to add some undocumented code to Guillaume's loop:

  (lambda ()
      (let ((form (get-next-queued-form)))
        (when form
          (eval form)))
      (setq ccl::*last-null-event-time* nil)   ; <=**** Here's the change

I wrote some code to test this. On my IIci, I still get only 112
calls per second. This is, I believe, largely due to the time taken by
the System 7 Finder.  System 6's Finder used a lot less time (I don't
remember the exact numbers, but I timed it once).


(defclass my-window (window) ())

(defvar *null-count* 0)

(defmethod window-null-event-handler ((w my-window))
  (incf *null-count*))

(defun time-null ()
  (let* ((w (make-instance 'my-window))
         time0 time1 time2 count1 count2)
     (setq *null-count* 0
           time0 (get-internal-real-time))
     (dotimes (i 200)
       (setq ccl::*last-null-event-time* nil)
     (setq count1 *null-count*
           *null-count* 0
           time1 (get-internal-real-time))
     (dotimes (i 200)
     (setq count2 *null-count*
           time2 (get-internal-real-time)))
    (window-close w)
    (values (/ (* count1 internal-time-units-per-second)
               (float (- time1 time0)))
            (/ (* count2 internal-time-units-per-second)
               (float (- time2 time1))))))

; Timed on a Mac IIci running System 7.0
? (time-null)