Syncing track tempo to riff/rhythm

How can I play a riff or lick and figure out the bpm to match it? Is there any quantanize feature for the metronome?

Thanks in advanced.

There are different options depending on the software used…

Try Project / Beat Calculator