Counting digital input

I want to make a bike computer by using a hall sensor. I wrote a code which shows if a magnet was detected and there's a variable which counts the number of magnet detectings, but I don't know how to count digital pulses on a second. Because if I would know pulses in a sec, then i could to count the speed / hour. So if you can, please help me! Thanks.

Record the value of millis() in a variable of data type unsigned long an make the counter variable zero. Use state change detection to detect pulses and count them into your count variable. Each time through loop() check to see if 1000 milliseconds has elapsed and check for state change. If so put the count into a variable to use in speed calculation and start a new cycle. The state change detection example is in the examples supplied with the IDE.