measure rpm of stepper motor

Here's info on how it works on a dc motor: https://brainy-bits.com/blogs/tutorials/speed-sensor-with-arduino

Instead of a dc motor, you could have a stepper motor there. But you have to understand my point. Your code says to your stepper motor when to take one step. The step is exactly one fraction of a revolution. It either takes this exact step or it does nothing, depending on how big the load is. There's no halfway step due to heavy load. Therefore you don't measure the rpm on a stepper motor. You get your rpm from understanding your own code.

If you still want to measure the rpm of the stepper motor, just do the same as they do for the dc motor in the page I linked. I mentioned a gearbox earlier, only because I still think it makes more sense to detect missed steps than rpm. For that you need an encoder platte that goes from 0 to 1 or 1 to 0 for each step your motor takes. If your motor does 1.8 degree steps, your plate needs 100 slots. With a 1:5 gearbox the plate needs 20 slots. With just any number of slots and no gear box you just have to perform extra arithmetics and end up in a rounded value of rpm.