diff --git a/Tools/scripts/build_tests/test_ccache.py b/Tools/scripts/build_tests/test_ccache.py index 428e8b1f43..740390e006 100755 --- a/Tools/scripts/build_tests/test_ccache.py +++ b/Tools/scripts/build_tests/test_ccache.py @@ -11,6 +11,7 @@ import os parser = argparse.ArgumentParser(description='test ccache performance') parser.add_argument('--boards', default='MatekF405,MatekF405-bdshot', help='boards to test') parser.add_argument('--min-cache-pct', type=int, default=75, help='minimum acceptable ccache hit rate') +parser.add_argument('--display', action='store_true', help='parse and show ccache stats') args = parser.parse_args() @@ -24,9 +25,21 @@ def ccache_stats(): m = re.match(r"cache.hit\D*(\d+)$", line) if m is not None: hits += int(m.group(1)) + m = re.match(r"cache.miss\D*(\d+)", line) if m is not None: miss += int(m.group(1)) + + m = re.match(r"\s*Hits:\s*(\d+)", line) + if m is not None: + hits += int(m.group(1)) + + m = re.match(r"\s*Misses:\s*(\d+)", line) + if m is not None: + miss += int(m.group(1)) + + if line.startswith("Primary"): + break return (hits, miss) @@ -35,6 +48,11 @@ def build_board(boardname): subprocess.run(["./waf", "clean", "copter"]) +if args.display: + (hits, misses) = ccache_stats() + print("Hits=%u misses=%u" % (hits, misses)) + sys.exit(0) + boards = args.boards.split(",") if len(boards) != 2: print(boards) @@ -42,6 +60,7 @@ if len(boards) != 2: sys.exit(1) os.environ['CCACHE_DIR'] = os.path.join(os.getcwd(), 'build', 'ccache') +subprocess.run(["ccache", "--version"]) subprocess.run(["ccache", "-C", "-z"]) build_board(boards[0]) subprocess.run(["ccache", "-z"])