From e598b2d135712d79577ac8ec95fc89735571687f Mon Sep 17 00:00:00 2001 From: Joshua Watt Date: Thu, 23 May 2024 10:44:54 -0600 Subject: bitbake: bitbake-hashclient: Improve ping command line options Adds a --quiet option to suppress the message for each ping, and report the median ping time. (Bitbake rev: 3c85b5e2d9b9c39507ed362aaa115b7f6f155966) Signed-off-by: Joshua Watt Signed-off-by: Richard Purdie --- bitbake/bin/bitbake-hashclient | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bitbake/bin/bitbake-hashclient b/bitbake/bin/bitbake-hashclient index 8d15604b34..5d6f67046b 100755 --- a/bitbake/bin/bitbake-hashclient +++ b/bitbake/bin/bitbake-hashclient @@ -242,18 +242,24 @@ def main(): def handle_ping(args, client): times = [] for i in range(1, args.count + 1): - print(f"Ping {i} of {args.count}... ", end="") + if not args.quiet: + print(f"Ping {i} of {args.count}... ", end="") start_time = time.perf_counter() client.ping() elapsed = time.perf_counter() - start_time times.append(elapsed) - print(f"{elapsed:.3f}s") + if not args.quiet: + print(f"{elapsed:.3f}s") mean = statistics.mean(times) + median = statistics.median(times) std_dev = statistics.pstdev(times) - print("------------------------") + if not args.quiet: + print("------------------------") + print(f"Number of pings: {len(times)}") print(f"Average round trip time: {mean:.3f}s") + print(f"Median round trip time: {median:.3f}s") print(f"Round trip time std dev: {std_dev:.3f}s") print(f"Min time is: {min(times):.3f}s") print(f"Max time is: {max(times):.3f}s") @@ -358,6 +364,7 @@ def main(): ping_parser = subparsers.add_parser('ping', help="Ping server") ping_parser.add_argument("-n", "--count", type=int, help="Number of pings. Default is %(default)s", default=10) + ping_parser.add_argument("-q", "--quiet", action="store_true", help="Don't print each ping; only print results") ping_parser.set_defaults(func=handle_ping) args = parser.parse_args() -- cgit v1.2.3-54-g00ecf