[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Event heartbeat.
- To: bhyde@gensym.com (Ben A. Hyde), cartier@math.uqam.ca (Guillaume Cartier)
- Subject: Re: Event heartbeat.
- From: bill@cambridge.apple.com (Bill St. Clair)
- Date: Fri, 5 Feb 1993 16:26:01 -0600
- Cc: info-mcl@cambridge.apple.com (Macintosh Common Lisp)
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:
>
>(function
> (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:
(function
(lambda ()
(loop
(let ((form (get-next-queued-form)))
(when form
(eval form)))
(setq ccl::*last-null-event-time* nil) ; <=**** Here's the change
(event-dispatch))))
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)
(without-interrupts
(setq *null-count* 0
time0 (get-internal-real-time))
(dotimes (i 200)
(setq ccl::*last-null-event-time* nil)
(event-dispatch))
(setq count1 *null-count*
*null-count* 0
time1 (get-internal-real-time))
(dotimes (i 200)
(event-dispatch))
(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)
112.42270938729624
60.10137581462708
|#