Re-implement TimeStampCounter.

It's error-prone to use string for statistics key.
Revised edition uses a local variable to have data, and has a helper class
to add data to the local variable.