summaryrefslogtreecommitdiff
path: root/hacks/analog.py
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-08-19 11:03:31 +0100
committerCarl Hetherington <cth@carlh.net>2015-08-19 11:03:31 +0100
commit30d1ece08b080010ac8256a655f2b629fa0bda7f (patch)
tree2ac3eec5f203665587e2fe738449a011f1eb3558 /hacks/analog.py
parentd16f3a8f05b99b23c90a4f7df62bc4ef8fc93ca2 (diff)
Some fixing to hacks/analog.py.
Diffstat (limited to 'hacks/analog.py')
-rw-r--r--hacks/analog.py39
1 files changed, 27 insertions, 12 deletions
diff --git a/hacks/analog.py b/hacks/analog.py
index 331c2d145..fa1246014 100644
--- a/hacks/analog.py
+++ b/hacks/analog.py
@@ -239,19 +239,34 @@ elif args.encoder_stats:
last = None
asleep = Time()
encoding = Time()
+ sending = Time()
+ remote_encoding_and_receiving = Time()
wakes = 0
for e in encoder_thread_events[t]:
- if e[1] == 'encoder-sleep':
- if last is not None:
- encoding += e[0] - last
- last = e[0]
- elif e[1] == 'encoder-wake':
- wakes += 1
- asleep += e[0] - last
- last = e[0]
+ if e[1] not in ['encoder-sleep', 'encoder-wake', 'start-remote-send', 'finish-remote-send',
+ 'start-remote-encode-and-receive', 'finish-remote-encode-and-receive']:
+ continue
+
+ if last is not None:
+ if last[1] == 'encoder-sleep':
+ asleep += e[0] - last[0]
+ elif last[1] == 'encoder-wake':
+ wakes += 1
+ encoding += e[0] - last[0]
+ elif last[1] == 'start-remote-send':
+ sending += e[0] - last[0]
+ elif last[1] == 'start-remote-encode-and-receive':
+ remote_encoding_and_receiving += e[0] - last[0]
+
+ last = e
print '-- Encoder thread %s' % t
- print 'Awoken %d times' % wakes
- total = asleep.float_seconds() + encoding.float_seconds()
- print 'Asleep: %s (%s%%)' % (asleep, asleep.float_seconds() * 100 / total)
- print 'Encoding: %s (%s%%)' % (encoding, encoding.float_seconds() * 100 / total)
+ print '\tAwoken %d times' % wakes
+ total = asleep.float_seconds() + encoding.float_seconds() + sending.float_seconds() + remote_encoding_and_receiving.float_seconds()
+ if total == 0:
+ continue
+ print '\tAsleep: %s (%.2f%%)' % (asleep, asleep.float_seconds() * 100 / total)
+ print '\tEncoding: %s (%.2f%%)' % (encoding, encoding.float_seconds() * 100 / total)
+ print '\tSending: %s (%.2f%%)' % (sending, sending.float_seconds() * 100 / total)
+ print '\tRemote encoding / receiving: %s (%.2f%%)' % (remote_encoding_and_receiving, remote_encoding_and_receiving.float_seconds() * 100 / total)
+ print ''