Allow memory_profiler to take a function for convenience