Timing in MCL

Mike Byrne byrne+ at andrew.cmu.edu
Tue Feb 11 16:52:02 EST 1997


At 14:09 -0500 97.02.11, Wayne Gray wrote:
>Greetings.
>
>Does anyone have experience in timing events (i.e., mouseclicks,
>keystrokes) in MCL? I am interested in getting as accurate as possible
>inter-event intervals.

This is a sticky question that I've dealt with a little lately, so I'll
take a stab.  As far as I can tell, there are two ways to approach this
problem:

(1) The Easy Way
The easy way is to make your screen objects key/mouse sensitive using
VIEW-KEY-EVENT-HANDLER and VIEW-CLICK-EVENT-HANDLER methods.  That is, you
override the default methods for the objects you're interested in, and
within your methods, you hit the clock via GET-INTERNAL-REAL-TIME.  The
clock is millisecond accurate *but* don't be misled into believing that the
the number you get out is really millisecond accurate.  Your handler will
get called probably zero to two ticks ("tick" = 1/60th of a second or about
17ms) after the event really happens, so the number you get back from the
clock will be kinda off.  (This a result of "float" in the OS's handling of
events, I don't think there's anything you can do about it.)  If you're
timing responses that take a couple seconds or so, the noise generated by
this inaccuracy is probably pretty marginal.  However, if you're trying to
do tight RT experiments where every millisecond counts, this probably won't
fit the bill.  Thus:

(2) The Hard Way
The hard way is to write code to directly poll the hardware.  Polling the
hardware should get you in the +/- 4 ms accuracy range, which is about the
limitations of computer hardware accuracy these days (despite what some
people may tell you, people on Wintel machines probably aren't doing any
better without special hardware).  Polling the hardware can be painful
because (a) you have to make a lot of low-level OS calls and (b) if your
code is actively polling the hardware, it can't be doing anything else
(unless you get into Time Manager tasks and such, but you again have to
sacrifice accuracy for this).

Hope that helps,
-Mike

=========================================================================
Mike "Sunburn" Byrne, Ph.D.                   |
byrne+ at andrew.cmu.edu, +1 412-268-3498        |  What if there were
Postdoc in Psychology/Cognitive Science       |    no hypothetical
Psychology Department, Carnegie Mellon Univ.  |      situations?
Pittsburgh, PA  15213                         |
http://act.psy.cmu.edu/ACT/people/byrne/index.html





More information about the ACT-R-users mailing list