The teensyduino library has some nice algorithms for this.
First of all you need to find the tach crossing times or indices. It appears that you have a digital signal. If amp is your signal then one way is:
trigamp = 2.5
tachcrossindice=findall((amp[2:end] .>= trigamp) .& (amp[1:end-1] .< trigamp))
It may well be that a for loop is faster. If your signal has been filtered then use linear interpolation to obtain a more accurate tach crossing time. You can adapt this for negative going pulses or if your duty cycle is 0.5, for both positive and negative going pulses.
Then you need to get the speed from the times. You have two choices, pick a time and count the number of pulses, or count the time between pulses. I use the later. I then normally smooth the rotational speed with the package “SmoothingSplines”, which seems to work well.