I have some techniques that don't take too much CPU but only work for specific circumstances.
What is your planned usage? I might be able to help.
Also, @PaulStoffregen is right and I might suggest an option in that light: "A sensor in a musicians shoe" Or rather, a tap tempo button. If you can simply tap the button a few times to the beat, you can use elapsedMillis to get the time between taps, and average if you like. you can even use the elapsedMillis variable with a modulo of the last valid tapped BPM to drive tempo synced events pretty easily.
But again, "the best way" is highly dependent on the details of what you plan to make.. The best way to detect tempo with a button is tap tempo, the best way to find the tempo on 4/4 techno is by lowpass filtering the kick into isolation, envelope following with an absolute value / another IIR filter and finding the rising edge of the amplitude from this. the best way to detect tempo in free jazz is to go do something else.