diff options
| -rwxr-xr-x | aergia | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -87,10 +87,7 @@ class Aergia(object): samples = defaultdict(lambda: 0) # number of times samples have been collected total_samples = 0 - - # the timestamp recorded last signal - last_signal_time = 0.0 - + # the (ideal) interval between samples signal_interval = 0.0 def __init__(self, signal_interval): @@ -98,8 +95,7 @@ class Aergia(object): @staticmethod def start(): - ''' - Turns on asyncio debug mode and sets up our signals. + '''Turns on asyncio debug mode and sets up our signals. Debug mode must be on by default to avoid losing samples. Debug mode is required to view the current coroutine being waited on @@ -108,12 +104,12 @@ class Aergia(object): ''' os.environ["PYTHONASYNCIODEBUG"] = "1" signal.signal(signal.SIGALRM, - Aergia.cpu_signal_handler) + Aergia.idle_signal_handler) signal.setitimer(signal.ITIMER_REAL, Aergia.signal_interval, Aergia.signal_interval) - Aergia.last_signal_time = Aergia.gettime() + @staticmethod def stop(): Aergia.disable_signals() Aergia.print_samples() @@ -143,12 +139,12 @@ class Aergia(object): signal.setitimer(signal.ITIMER_REAL, 0) @staticmethod - def cpu_signal_handler(sig, frame): + def idle_signal_handler(sig, frame): + '''Obtains and records which lines are currently being waited on.''' keys = Aergia.compute_frames_to_record() for key in keys: Aergia.samples[Aergia.frame_to_string(key)] += 1 Aergia.total_samples += 1 - Aergia.last_signal_time = Aergia.gettime() @staticmethod def compute_frames_to_record(): |
