Well this kind of measuring using pulses is widely used in manufacturing, for example robotics.
NOTICE that it measures the duration
of a pulse, so there is no loose of pulse time here.
Depending on how you set pulsin you can measure the time of low signal or high signal, after a previous pulse.
Light itself is extreme fast wheel side hole should be small (needle).. and measure the LOW signal duration
instead of a hole you might put some small reflecting on your wheel to and point a led or so next to a LDR
..you could also work with large holes like 1/4 of diameter but math below will be different then
..but wouldbe easy once you get it.
Of-course it takes time to measure using PulseIn but the arduino will do nothing else until it has a next pulse.
Its the smallest code to to measure it.
for distance measuring, maybe something different might be better... dough you can work around it with some math
but if it is precise speed your after PulseIn is quite good, as it uses minimal code to measure time and so its more accurate.
to improve precision i would do a number a measurements then average them, and then display it
// 1000 micro seconds = 0,001 seconds
// 1 minute = 60000000 microseconds
// 1 hour = 360000000 microseconds
// km/hour >> lets say wheel diameter size = 217 mm (thats small)
// diameter 217mm * pi = 681,725mm
// so a full cycle gets you 681,725 mm away or ~ 0.000681725 km so 1/0,00681725 = 1 km = 1466,867 cyles
// so if you do 1466,867 cylces in a hour then your speed = 1km/p hour
// so ( 1466,867 cycles per hour ) equals 1466,867 cycles per 360000000 microseconds
// thus 360000000 / 1446,867 = microsecond time required for 1 cycle
// = 1 cycle should be done in 245421,023174 microseconds = 1km/hour (large number but 1 km/h is quite slow)
// so finally >> 1 / 245421,023174 * you measurement time = yourspeed in km/hour
// >> this math wont work with a integers, use dword or float
// >> also you can put 1/245421,023174 in a constant so you wont need to calculate it each time
// ~you might double check it but i think its oké
// (and i think previous person forgot pi x diameter, because many more cycles are needed )
although i have to agree that if the wheel stands still its not measuring speed and the execution flow would halt.
on the other hand, this way allows for rapid measurements might be nice for quadcopter motor speed measuring etc.
but the required code for this would be small and likely fit in a tinyduno too, then it could respond speed to a normal arduino, if you dont want execution flow to stop.. (i wonder dough, maybe speed sensors allready exist ?).
On the otherhand a tiny duno a led and a LDR equals a speed meter below 4 dollar or so, thats not expenisve
another thing to use averages i recommend to use the last x samples
you might do avSpeed = ( avSpeed * 9 + newspeedmeasurement ) / 10
PS a handy site to do conversions :http://www.convertunits.com/from/millimetre/microsecond/to/kilometers+per+hour
you can do all kind of conversions personally i prefer that, also you can calculate inside google search