1

I'd like to measure the reaction time of a user. In this example, I'm using actionscript, but the concept is really what is important, so feel free to answer in your language of choice, if you want to show any code.

The user sits in front of a screen and will be presented with a red dot. When they see the red dot, they hit the space bar.

My logic is as follows: make red dot visible, create a new date, wait for spacebar, create a new date, find the difference in milliseconds using a TimeSpan object.

//listen for the keystroke
this.systemManager.stage.addEventListener(KeyboardEvent.KEY_DOWN, catchSpace, true, 1);
...
if (e.keyCode == Keyboard.SPACE) {
  e.preventDefault();
  this.dispatchEvent(new PvtEvent(PvtEvent.BTN_CLICK));
}

//show the red dot, making note of the time
redDot.visible = true;
this.startCount=new Date();

//user clicks the space bar
this.endCount=new Date();
var timeSpan:Number=TimeSpan.fromDates(this.startCount, this.endCount).totalMilliseconds;

I feel like this should work, but I'm getting some values that are disconcerting. Here is a typical result set:

[254, 294, 296, 305, 306, 307, 308, 309, 310, 308, 312, 308, 338, 346, 364, 370, 380, 387, 395, 402, 427]

Notice that some of the values are close, and 308 is recorded multiple times. So, my questions are as follows:

  1. Is my code, or the logic I'm using, flawed in some way?
  2. What is the probability that the user is able to produce repeat times?
  3. If the probability is low, then what am I missing here?

I should also note that I have (quite accidentally) received a 12ms response time. I was testing the app, and happen to hit the space bar just as the red dot appeared. So, I am doubting that my code cannot judge accurate time, at least to an accuracy of ±12ms :) .

Community
  • 1
  • 1
Stephano
  • 5,716
  • 7
  • 41
  • 57

2 Answers2

0

I would suppose that reaction time have somewhat normal distribution, so it might be the case that some results are more likely to occur several times. Your reaction times are from 254 to 427, that is 174 possible different results. so question is in x tests, how likely is it that in x tests, some are the same? since it is probably normaly distributed this increases.

If you run it on your computer, then remember other applications/threads interact with the CPU. Further, some latency in the OS, and if you connect via USB or PS/2 (USB-device/hub is polled, while PS/2 is direct to the IRQ)

Viktor Mellgren
  • 4,318
  • 3
  • 42
  • 75
0
  1. No, the logic seems fine. This is a perfectly simple way to measure time to the ms.
  2. Turns out human beings and computers can seldom do anything to millisecond accuracy.
  3. The thing I'm tripping on is Flash!

After a few months of on and off testing, we figured out the issue; the language. From the ASDOC on the flex Timer:

A delay lower than 20 milliseconds is not recommended. Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems.

Flash runs with a frame rate of 60 FPS. I guess this means that if you try to measure time, and want to be accurate to less the 16 ms, you are out of luck. However this does explain why I would see repeating values, as anything in this "60 FPS window" was just being measured as the same time.

Stephano
  • 5,716
  • 7
  • 41
  • 57