def start(profile_bench=coro.rusage_bench): """Start the profiler. :Parameters: - `profile_bench`: The profiler type to use. """ p = coro.new_profiler(profile_bench) p.start()
def go(fun, *args, **kwargs): """Start the profiler on a function. This will start the profiler, and then call the provided function. The profiler will shut down once the function returns. Additional arguments provided are passed to the function. This will display the results to stdout after the function is finished. :Parameters: - `fun`: The function to call. :Keywords: - `profile_filename`: The name of the file to save the profile data. Defaults to '/tmp/coro_profile.bin'. - `profile_bench`: The bench object type to use. Defaults to `coro.rusage_bench`. """ if kwargs.has_key('profile_filename'): profile_filename = kwargs['profile_filename'] del kwargs['profile_filename'] else: profile_filename = '/tmp/coro_profile.bin' if kwargs.has_key('profile_bench'): profile_bench = kwargs['profile_bench'] del kwargs['profile_bench'] else: profile_bench = coro.rusage_bench p = coro.new_profiler(profile_bench) p.start() try: return fun(*args, **kwargs) finally: total_ticks = p.stop() user_ticks = _dump(p, profile_filename)
def go (fun, *args, **kwargs): """Start the profiler on a function. This will start the profiler, and then call the provided function. The profiler will shut down once the function returns. Additional arguments provided are passed to the function. This will display the results to stdout after the function is finished. :Parameters: - `fun`: The function to call. :Keywords: - `profile_filename`: The name of the file to save the profile data. Defaults to '/tmp/coro_profile.bin'. - `profile_bench`: The bench object type to use. Defaults to `coro.rusage_bench`. """ if kwargs.has_key('profile_filename'): profile_filename = kwargs['profile_filename'] del kwargs['profile_filename'] else: profile_filename = '/tmp/coro_profile.bin' if kwargs.has_key('profile_bench'): profile_bench = kwargs['profile_bench'] del kwargs['profile_bench'] else: profile_bench = coro.rusage_bench p = coro.new_profiler (profile_bench) p.start() try: return fun (*args, **kwargs) finally: total_ticks = p.stop() user_ticks = _dump (p, profile_filename)