How to record time spent in different phases of a recursive loop
I made an experiment in which participants can switch between two parts of information (two 'screens') by pressing the 'up' key. They can keep on switching until they finally make a decision (by pressing one of two other keys).
Now I want to record how much time they spend on each part of information until they make a choice. Ultimately I am interested in how much time they spent in total on each part of information.
My question is what is the best way to record this?
I am not sure what is the best way to explain my question,
but in case it helps, this screenshot shows the outline of this sequence:
The design of the solution I was thinking about:
Start by recording the time between each switch by storing a t1 - t0 calculation into a variable in both screen_first_script and screen_second_script. Then make a new t1-t0 variable each time those inline scripts are called (i.e. each time a switch is made). Then sum those variables up at the end, per screen.
If this is correct, what is the best way to let my script infinitely keep on producing new t1-t0 variables?
Or is there a better way to record the different amounts of time spent at each screen?
I hope my question makes sense!