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

Re: Timing Problems with DrScheme and Mac OS



Quoting stefan.schadwinkel@s2000.tu-chemnitz.de:
> The problem we're facing is quite simple, we want an accurate time
> messurement of the users keystrokes. (We show a word, the individual
> should hit a key and i want to take the time between showing the word
> and the keystroke)

Whether this is even possible in DrScheme depends on how much accurracy
you need. On the Mac, in particular, DrScheme has to cooperatively
yield to other programs...

> I should say, that running "current-milliseconds" 6 times and
> displaying its results shows something like this:
>  
> 387850
> 387850
> 387850
> 387850
> 387866
> 387866
> 
> mostly, the numbers are ending on 33, 66, 50..
> 
> well, this is much too inaccurate for our purposes

... and I worry that a yield can certainly take more than 1/60 of a
second (depending on what the Finder wants to do).

PsyScope is a Mac programs designed for reliable psychology
experiments. It does not cooperate with other applications in the way
that DrScheme has to. Instead, it takes over the machine and polls
hardware directly.

Pre-emptive multi-tasking can avoid the problem, to some degree, by
ensuring that each application is executed often enough --- perhaps
enough for a reliable experiment these days. That apparently wasn't the
case 8 years ago, though; MacOS's lack of pre-emptive scheduling was
actually a benefit (for a change) in PsyScope.

> Now I ask, if you got some hints or ideas to get accurate millisecond
> values.. I don't about care small inaccurancies, but it should be
> better than this one tenth of second.

It might be easier to write a small extension in C. I'd be surprised if
AppleEvents could provide the accurracy that you want (again, because
AppleEvents rely on expensive cooperative context switches).

The following page in the MacOS 8/9 documentaion shows how to compute
elapsed time in microseconds:

 http://developer.apple.com/techpubs/mac/Processes/Processes-62.html#HEADING62-0

Matthew