If you're a regular coffee drinker and grind your own beans, you'll know there can be quite a loss of wastage and fiddling about getting the right dose in the portafilter. If you have a dosing grinder, like the Rancilio Rocky, the job is simpler - if you're grinding large amounts at the one time. Or for small amounts, you can get by with just counting the grinder turn on time - and doing some +/- adjustment at the end. (Or using a measure for just the beans you want to grind - which is a lot of extra fiddling).
But there is a better way! Use a digital timer. Unfortunately, there is no such thing for controlling grinders that is compact and exact. But you can build one for around $100 in bits and some time. The video shows it in action. The button used is all that's needed and the timer switches off after use. The other buttons are to turn the system on continuously for programming and to allow manual grinder control. You can download the circuit design and parts list if you feel the urge to do this yourself. (Don't bother asking me for another one!)