The previous advice about the Serial.print() statements extending the sampling time is valid. However, instead of waiting a certain time and seeing how many pulses you count that time, a better way is to measure and store the time interval between interrupts, and calculate the rpm from that interval. Like this:
volatile unsigned long lastPulseTime;
volatile unsigned long pulseInterval;
void rpm_func()
{
unsigned long now = micros();
pulseInterval = now - lastPulseTime;
lastPulseTime = now;
}
void loop()
{
noInterrupts();
unsigned long interval = pulseInterval;
interrupts;
unsigned int rpm = 60000000L/interval;
... // do something with 'rpm'
}
You don't need to call attachInterrupt() in loop(), just calling it in setup() is enough.
Missing from this example is code to detect when the the pulses have stopped, and set rpm to zero when that happens. I leave that to you to write.