Implement statistical profiling.

Statistical profiling allows profiling already running threads, with
controllable overhead (trade-off between measure duration to get relevant
values and overhead).
Experimental for the moment, but generates sane-looking results.