5 from ctypes import c_ushort, c_int, c_ulonglong
9 print("USAGE: %s [--process|histogram]" % argv[0])
12 print("Hit Ctrl-C to end.")
20 if argv[1] == "--histogram":
22 elif argv[1] == "--process":
27 b = BPF(src_file="dbus-latency.c")
29 b.attach_uprobe(name="dbus-1", sym="_dbus_connection_message_sent_unlocked", fn_name="get_msg_addr")
30 b.attach_uprobe(name="dbus-1", sym="dbus_connection_dispatch", fn_name="get_msg_latency")
31 b.attach_uprobe(name="gio-2.0", sym="g_dbus_message_lock", fn_name="g_get_latency")
38 if mode =="histogram":
39 b["latency_histo"].print_log2_hist("ms")
41 print ("%10s %20s %10s %10s %10s" % ("PID", "COMM", "MIN", "AVG", "MAX"))
42 latency = b["msg_latency"]
43 for v, p in sorted(latency.items(), key=lambda latency: latency[1].avg, reverse=True):
44 print("%10d %20s %10d %10d %10d" % (v.pid, v.comm.encode('string-escape'), int(p.min), int(p.avg), int(p.max)))