# timing questions

**URL:** <https://psychtoolbox.discourse.group/t/timing-questions/1761>\
**Category:** Uncategorized\
**Created:** [January 29, 2007, 12:12am UTC](https://psychtoolbox.discourse.group/t/timing-questions/1761 "2007-01-29T00:12:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pperakakis](https://avatars.discourse-cdn.com/v4/letter/p/e47774/32.png) [@pperakakis](https://psychtoolbox.discourse.group/u/pperakakis)\
**Post date:** [January 29, 2007, 12:12am UTC](https://psychtoolbox.discourse.group/t/timing-questions/1761/1 "2007-01-29T00:12:05Z")

</div>

Dear group,  
I am using the last beta version of PsychToolbox with Matlab R2006a and   
a Turion 64x2 processor running on windows XP. I am posting this message   
because I detected some timing precision problems and I would like to   
ask your opinion about what may be causing them and if there is any way   
to improve timing precision. The simple script I used to detect the   
problems is the following:  
  
[w rect]=Screen('OpenWindow', 0);  
Priority(7);  
gray=GrayIndex(0);  
Screen('DrawText', w, 'A' , 200, 100, [0, 0, 0, 0]);  
flipini=GetSecs;  
[VBLTimestamp StimulusOnsetTime FlipTimestamp]=Screen('Flip', w);  
WaitSecs(2);  
endwait=GetSecs;  
[VBLTimestamp2 StimulusOnsetTime2 FlipTimestamp2]=Screen('Flip', w);  
Screen('CloseAll');  
  
I attach a txt file with the messages I receive in my command window   
after executing the script. The one that worries me most is:  
  
WARNING: PTB's Screen('Flip') command missed the requested stimulus   
presentation deadline  
WARNING: a total of 2 times during this session!  
  
The timimng problems become obvious by calculating some of the variables:  
StimulusOnsetTime-flipini=0.00672851696254, which means a delay of 6ms  
and  
StimulusOnsetTime2-endwait=0.01884155754124, a delay of 18ms!  
  
Another script I use to prompt timings is:  
  
Priority(7);  
times=zeros(1,10000);  
for i=1:10000;times(i)=Getsecs;end  
d=diff(times);  
max(d)  
  
Here, max(d) fluctuates between 0.0001 (which is good, but appears   
rarely) and 0.005. mean(d), however is always 0.  
  
I would appreciate any opinion about these timings. Are they normal? Do   
they have to do with the monitor refresh rate? If the monitor refresh   
rate is 60Hz how come I have a 18ms delay? Are there ways to improve   
precision? Can I at least be certain that timing errors are constant?  
 Thank you all for your attention,  
  
Pandelis Perakakis  
PhD researcher in psychophysiology,  
University of Granada,  
Spain
