Calculating ms differences within the loop

I have created a trip circuit, but I need measure how long the object trips the laser (to a phototransistor) for so that I can calculate the velocity of the object.

I have the code which can do the calculation, but what is the speed of the void loop()? If its measurement is slower than ms then my solution will not work. Does anyone know the speed of the loop, or if there is a better way to measure how long my trip has been tripped for?

Thanks for your help in-advance.

Use micros() or millis() as a timestamp.
The rate loop runs will vary depending on how much work it has to do.

Edit: spelling

Thanks, but my understanding is that micros() is from the time the program starts. I will need the method micros() to be reset to 0 post the event, but I cannot find anything will allow this and also micros() would need to be triggered upon the trip event becoming positive (or negative) as opposed to when the program starts

cbruiners:
Thanks, but my understanding is that micros() is from the time the program starts. I will need the method micros() to be reset to 0 post the event, but I cannot find anything will allow this and also micros() would need to be triggered upon the trip event becoming positive (or negative) as opposed to when the program starts

Yesterday I wanted to know how long it took to drive from my house to the store. I looked at my watch, and it was 3:45, so I reset my watch to 0 (well, 12:00), and set out. When I got there, I had the time showing on my watch.

Does that sound reasonable? No? What's a better method?

How about this one? I left my watch set to 3:45, and when I got to the store, it showed 3:58, so I just used subtraction to find the time it took.

So....

unsigned long start_time = millis();

and later...

unsigned long duration = millis() - start_time;

Same for micros().

Well, millis() and micros() work the