diff options
Diffstat (limited to 'aergia')
| -rwxr-xr-x | aergia | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -111,14 +111,14 @@ class Aergia(object): @staticmethod def print_samples(): - '''Pretty-print profiling information.''' + '''Pretty-print profiling results.''' if Aergia.total_samples > 0: - print("Results") print("FILE\tFUNC\tPERC\tACTUAL+CALCULATED=SECONDS") for key in Aergia.sort_samples(Aergia.samples): Aergia.print_sample(key) else: - print("No samples were gathered. This is likely a bug.") + print("No samples were gathered. If you are using concurrency, " + "this is likely a bug and you may run the profiler again.") @staticmethod def print_sample(key): @@ -157,7 +157,7 @@ class Aergia(object): '''Collects all stack frames that Aergia actually processes.''' frames = [] if Aergia.is_event_loop_running(): - frames = [task.get_coro().cr_frame for task in asyncio.all_tasks()] + frames = Aergia.get_current_idle_tasks() # Process all the frames to remove ones we aren't going to track. new_frames = [] @@ -187,6 +187,16 @@ class Aergia(object): return new_frames @staticmethod + def get_current_idle_tasks(): + '''Obtains the stack of frames of all currently idle tasks.''' + curr_task = asyncio.current_task() + return [ + task.get_coro().cr_frame + for task in asyncio.all_tasks() + if task is not curr_task + ] + + @staticmethod def frame_to_string(frame): '''Pretty-prints a frame as a function/file name and a line number. Additionally used as a key for tallying lines.''' |
