Speedup python function monitor

This PR speeds-up the pure python function monitor by ~17 times. The step by step bench- marking code is also provided.