diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2024-05-22 10:29:43 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-05-23 11:27:08 +0100 |
commit | 76421d5742ecca6344f3035378f89c2fc3a5ae05 (patch) | |
tree | 27c3e839babde08e177c8c49363e462983f9a31e /bitbake | |
parent | 7812f104db9a2c72ea4dd5c458a4d50613360b08 (diff) | |
download | poky-76421d5742ecca6344f3035378f89c2fc3a5ae05.tar.gz |
bitbake: bitbake-hashclient: Add ping command
Adds a ping subcommand to bitbake-hashclient which can be useful to
measure connection latency
(Bitbake rev: 337487fdffae92091fc33b2346d46c39db5a130f)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rwxr-xr-x | bitbake/bin/bitbake-hashclient | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/bitbake/bin/bitbake-hashclient b/bitbake/bin/bitbake-hashclient index 610787ed2b..e1e1144644 100755 --- a/bitbake/bin/bitbake-hashclient +++ b/bitbake/bin/bitbake-hashclient | |||
@@ -16,6 +16,7 @@ import time | |||
16 | import warnings | 16 | import warnings |
17 | import netrc | 17 | import netrc |
18 | import json | 18 | import json |
19 | import statistics | ||
19 | warnings.simplefilter("default") | 20 | warnings.simplefilter("default") |
20 | 21 | ||
21 | try: | 22 | try: |
@@ -225,6 +226,26 @@ def main(): | |||
225 | print("true" if result else "false") | 226 | print("true" if result else "false") |
226 | return 0 | 227 | return 0 |
227 | 228 | ||
229 | def handle_ping(args, client): | ||
230 | times = [] | ||
231 | for i in range(1, args.count + 1): | ||
232 | print(f"Ping {i} of {args.count}... ", end="") | ||
233 | start_time = time.perf_counter() | ||
234 | client.ping() | ||
235 | elapsed = time.perf_counter() - start_time | ||
236 | times.append(elapsed) | ||
237 | print(f"{elapsed:.3f}s") | ||
238 | |||
239 | mean = statistics.mean(times) | ||
240 | std_dev = statistics.pstdev(times) | ||
241 | |||
242 | print("------------------------") | ||
243 | print(f"Average round trip time: {mean:.3f}s") | ||
244 | print(f"Round trip time std dev: {std_dev:.3f}s") | ||
245 | print(f"Min time is: {min(times):.3f}s") | ||
246 | print(f"Max time is: {max(times):.3f}s") | ||
247 | return 0 | ||
248 | |||
228 | parser = argparse.ArgumentParser(description='Hash Equivalence Client') | 249 | parser = argparse.ArgumentParser(description='Hash Equivalence Client') |
229 | parser.add_argument('--address', default=DEFAULT_ADDRESS, help='Server address (default "%(default)s")') | 250 | parser.add_argument('--address', default=DEFAULT_ADDRESS, help='Server address (default "%(default)s")') |
230 | parser.add_argument('--log', default='WARNING', help='Set logging level') | 251 | parser.add_argument('--log', default='WARNING', help='Set logging level') |
@@ -322,6 +343,10 @@ def main(): | |||
322 | unihash_exists_parser.add_argument("unihash", help="Unihash to check") | 343 | unihash_exists_parser.add_argument("unihash", help="Unihash to check") |
323 | unihash_exists_parser.set_defaults(func=handle_unihash_exists) | 344 | unihash_exists_parser.set_defaults(func=handle_unihash_exists) |
324 | 345 | ||
346 | ping_parser = subparsers.add_parser('ping', help="Ping server") | ||
347 | ping_parser.add_argument("-n", "--count", type=int, help="Number of pings. Default is %(default)s", default=10) | ||
348 | ping_parser.set_defaults(func=handle_ping) | ||
349 | |||
325 | args = parser.parse_args() | 350 | args = parser.parse_args() |
326 | 351 | ||
327 | logger = logging.getLogger('hashserv') | 352 | logger = logging.getLogger('hashserv') |