Split profiling out into performance.py
Add some doctests