# debug_zmq_dump.py import zmq, time addr = "tcp://localhost:9091" topic = "" # change if publisher uses a non-empty topic prefix ctx = zmq.Context() # Increase IO threads for 10Gbps link ctx.set(zmq.IO_THREADS, 4) sub = ctx.socket(zmq.SUB) # Massive 128MB buffer to ensure we don't drop frames sub.setsockopt(zmq.RCVBUF, 128 * 1024 * 1024) sub.setsockopt(zmq.RCVHWM, 5000) sub.connect(addr) sub.setsockopt_string(zmq.SUBSCRIBE, topic) print(f"ULTRA-FAST Benchmark: Connected to {addr}") # Tracking start_time = time.time() last_print_time = start_time frame_count = 0 total_bytes = 0 try: while True: # Step 1: Just suck the bytes off the wire as fast as physically possible parts = sub.recv_multipart() # Step 2: Account for the data size frame_size = sum(len(p) for p in parts) total_bytes += frame_size frame_count += 1 # Step 3: Print stats every 2 seconds for stability now = time.time() if now - last_print_time >= 2.0: elapsed = now - last_print_time fps = frame_count / elapsed mbps = (total_bytes / 1024 / 1024 * 8) / elapsed print(f"STREAM STATS: {fps:.2f} FPS | {mbps:.1f} Mbps | Frame: {frame_size/1e6:.2f} MB") # Reset frame_count = 0 total_bytes = 0 last_print_time = now except KeyboardInterrupt: print("\nBenchmark stopped.")