TimerTest fails on Windows unless the sleep time is set to at least a
millisecond (1,000 microseconds). Keep it nice and low for other platforms
though, because the sleep time is wasted.
The accuracy of getrusage() is limited by the resolution
of software clock as described in
http://www.kernel.org/doc/man-pages/online/pages/man7/time.7.html
The assertions required a timer with microsecond accuracy.
However, we don't necessarily want the timer, and we don't
want to add some time-consuming processes to the test code because
we normally build programs again and again, which means
we want to run unit tests as quickly as possible.
- Add a high resolution timing function to measure the
wall-clock time by gettimeofday().
- Now the Timer class use getrusage() to measure the elapsed
CPU time as KenLM does.
- Revive Timer::restart().
- Add Timer::ToString() for reporting the detail statistics
as well as for debugging.
- Add a simple unit test for Timer.