Difference between mouse.mouseClock.getTime() and mouse.time?

OS: Windows 10 with Intel Graphics
PsychoPy version: 2022.2.x
Standard Standalone?: yes

What are you trying to achieve?:
I am working on some tests involving mouse responses. In the process of trying to maximize the precision of this timing, I have identified multiple strategies to acquire reaction time on mouse click.

Option 1 (built-in). In the Data tab of mouse component use the following settings:

  • save mouse state is set to on click
  • time relative to is set to mouse onset
  • save onset/offset times and sync timing with screen refresh keep default values

Option 2 (coded). A code component contains the following code:

  • In Begin Routine:
mouse_clicked = False
  • In Each Frame:
if 1 in mouse.getPressed() and not mouse_clicked:
    rt = mouse.mouseClock.getTime()
    mouse_clicked = True
  • The javascript version is auto-translated with no modifications

There are timing discrepancies between these two options.
When running the experiment in Standalone PsychoPy, Option 1 (built-in) is 3 to 10 ms slower than Option 2 (coded).

What did you try to make it work?:

  • I tested whether this discrepancy was related to screen synchronization by toggling the sync timing with screen refresh option. Regardless of whether this option is/is not checked in the the mouse component, I still observe the 3-10ms discrepancy between the built-in and coded options.
  • I tested whether this discrepancy was consistent across Python and Javascript. In standalone Psychopy, Option 1 (built-in) is 3 to 10 ms slower than Option 2 (coded). In Javascript (run using the run JS for local debug option), Option 1 (built-in) is 1 to 6 ms slower than Option 2 (coded).

Do others also experience this difference between Option 1 and Option 2 timing?

I find this difference between built-in and coded mouse timing interesting, as I would expect manually coded RT recording to be slower than the built-in recording. I am wondering if it has something to do with mouse.time acquiring the timing information in a different manner than using mouse.mouseClock.getTime(). I reviewed the PsychoPy API, but was unable to find descriptions on how mouse.time differs from mouse.mouseClock.getTime(). I am interested to hear if anyone has insights into the differences between mouse.time and mouse.mouseClock.getTime() as well as the differences between JS and Python for timing (the discrepancy was much smaller in JS).

Thank you ,

Further timing exploration:
The variable t is the Routine’s clock, which I tried using as a ‘control’ time by saving it in Option 2’s code.

When time relative to is set to mouse onset:

  • Option 1 (built-in, mouse.time) is equal to t
  • Option 2 (coded, mouse.mouseClock.getTime()) is faster than t

When time relative to is set to Routine:

  • Option 1 (built-in) is slower than t
  • Option 2 (coded) is equal to t

I would expect when time relative to is set to mouse onset, the mouse-based times should appear faster than the Routine based time, because the mouse component should initialize shortly after the routine. Likewise, when time relative to is set to Routine, the mouse-based times should appear approximately equal to the routine based times, because all times should be relative to when the routine began.
Therefore, the numbers produced by the coded Option 2 with mouse.mouseClock.getTime() make sense based on what I would expect.

I am curious to understand why mouse.time differs from these values.