You can measure this in either RPM (revolutions per minute) or frequency (cycles per second).
Whether it be a minute or a second, you count the number of times you get a pulse and at the end of the minute/second you copy the total to your variable and reset the counter variable. If you need a fasster update rate, you can count for fractions of minute/second and do the calculation to show it in terms of RPM/frequency.
My first concern when solving this issue is how fast the magnet is going past the sensor (ie how many pulses per second).
If it is slow, you can do it in your main loop as long as you don't have any blocking instructions (such as
If it is fast you will probably have to look into an interrupt. When the pin goes high, it jumps to the interrupt function and increments a counter. Check the input section for libraires that make the interrupt process easy (or do it the old fashioned way, your choice). Some of the button libraries have interrupt specific functions.