File tree Expand file tree Collapse file tree 1 file changed +22
-5
lines changed
Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -19,10 +19,23 @@ def main(c_args: argparse.Namespace):
1919 elif c_args .ordinal_offset :
2020 headers ["X-StreamFromOrdinal" ] = c_args .ordinal_offset
2121
22+ total_bytes = 0
23+ total_messages = 0
24+ min_bytes = 1_000_000
25+ max_bytes = 0
2226 ws = Client .connect (c_args .location , headers = headers )
2327 try :
2428 while True :
29+
2530 data = ws .receive ()
31+
32+ # Collect some stats
33+ data_len = len (data )
34+ total_bytes += data_len
35+ min_bytes = min (min_bytes , data_len )
36+ max_bytes = max (max_bytes , data_len )
37+ total_messages += 1
38+
2639 msg_type = "(unknown)"
2740 msg = "(unknown)"
2841 ordinal = "(unknown)"
@@ -46,11 +59,15 @@ def main(c_args: argparse.Namespace):
4659 else :
4760 ordinal = "(not present)"
4861 timestamp = "(not present)"
49- print ("---------" )
50- print (f" ORDINAL: { ordinal } " )
51- print (f"TIMESTAMP: { timestamp } " )
52- print (f" TYPE: { msg_type } " )
53- print (f" BODY: { msg } " )
62+ print ("-----------" )
63+ print (f" ORDINAL: { ordinal } " )
64+ print (f" TIMESTAMP: { timestamp } " )
65+ print (f" TYPE: { msg_type } " )
66+ print (f" BODY: { msg } " )
67+ print (f"TOTAL BYTES: { total_bytes } " )
68+ print (f" MIN BYTES: { min_bytes } " )
69+ print (f" MAX BYTES: { max_bytes } " )
70+ print (f" AVG BYTES: { int (total_bytes / total_messages + 0.5 )} " )
5471 except (KeyboardInterrupt , EOFError , ConnectionClosed ):
5572 ws .close ()
5673
You can’t perform that action at this time.
0 commit comments