X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=hacks%2Fanalog.py;h=355dabe495e5f6f906e9da9851c9b9ce22f1d6bf;hb=508c04eb521150db05cd8e6b9f28bbe8f0eecd01;hp=c58af76ee53972ba0341dba4e69cd96485fbc798;hpb=dae7fea98a5ca43d7e278b6381afcb5ccd1a310b;p=dcpomatic.git diff --git a/hacks/analog.py b/hacks/analog.py index c58af76ee..355dabe49 100644 --- a/hacks/analog.py +++ b/hacks/analog.py @@ -19,6 +19,7 @@ parser.add_argument('--encoder-dump', help='dump activity of the specified encod parser.add_argument('-e', '--encoder', help='encoder index (from 0)') parser.add_argument('--from', help='time in seconds to start at', type=int, dest='from_time') parser.add_argument('--to', help='time in seconds to stop at', type=int, dest='to_time') +parser.add_argument('--max-encoder-threads', help='maximum number of encoder threads to plot with --encoder-threads', type=int, default=None) args = parser.parse_args() def find_nth(haystack, needle, n): @@ -116,10 +117,13 @@ while True: try: T = Time(time.mktime(time.strptime(l[:s], "%d.%m.%Y %H:%M:%S"))) except: - x = l[:s] - if not x.endswith('M'): - x += 'M' - T = Time(time.mktime(time.strptime(x, "%d/%m/%Y %H:%M:%S %p"))) + try: + T = Time(time.mktime(time.strptime(l[:s], "%d/%m/%Y %H:%M:%S"))) + except: + x = l[:s] + if not x.endswith('M'): + x += 'M' + T = Time(time.mktime(time.strptime(x, "%d/%m/%Y %H:%M:%S %p"))) message = l[s+2:] # T is elapsed time since the first log message @@ -160,6 +164,11 @@ elif args.encoder_threads: # y=0 thread is sleeping # y=1 thread is awake # y=2 thread is encoding + # y=3 thread is awaiting a remote encode + + if args.max_encoder_threads is not None: + encoder_threads = encoder_threads[0:min(args.max_encoder_threads, len(encoder_threads))] + plt.figure() N = len(encoder_threads) n = 1 @@ -174,6 +183,8 @@ elif args.encoder_threads: continue if args.to_time is not None and e[0].float_seconds() >= args.to_time: continue + if e[1] == 'start-remote-send' or e[1] == 'finish-remote-send' or e[1] == 'start-remote-receive' or e[1] == 'finish-remote-receive': + continue x.append(e[0].float_seconds()) x.append(e[0].float_seconds()) y.append(previous) @@ -185,6 +196,10 @@ elif args.encoder_threads: y.append(2) elif e[1] == 'finish-local-encode': y.append(1) + elif e[1] == 'start-remote-encode': + y.append(3) + elif e[1] == 'finish-remote-encode': + y.append(1) else: print>>sys.stderr,'unknown event %s' % e[1] sys.exit(1)