Suggestions on code for reading square wave input

I have a speed and direction sensor and the speed portion sends a square wave, and ideas on what the code would be to read this as a speed? I would assume some type of count function over a period of time?

Check the pulsein() function

http://arduino.cc/en/Reference/PulseIn

It might do the trick depending on voltage level and frequency.