Bugfix: Adding locks around map update.

Discovered a race condition while recording measurements for STREAM with
multiple threads. Using a single global lock to protect writes to
function_count. There still does exist a race condition in that reads are not
protected by the lock but the nature of the reads doesn't affect the
correctness by substantial margins.