Timing is a big concern for all scientists. Fortunately MATLAB isn't that bad in timing questions as many people say! Of course some preparations have to be done and care must be taken, but this is described in a very good paper.
Wael F. Asaad and Emad N. Eskandar; Achieving behavioral control with millisecond resolution in a high-level programming environment (Journal of Neuroscience Methods (2008) 173:235-40)