Tools: fixed ccache test for newer ccache version

This commit is contained in:
Andrew Tridgell 2023-09-03 08:17:05 +10:00
parent 49cb017ca5
commit 21db41f5b8
1 changed files with 19 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import os
parser = argparse.ArgumentParser(description='test ccache performance') parser = argparse.ArgumentParser(description='test ccache performance')
parser.add_argument('--boards', default='MatekF405,MatekF405-bdshot', help='boards to test') 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('--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() args = parser.parse_args()
@ -24,9 +25,21 @@ def ccache_stats():
m = re.match(r"cache.hit\D*(\d+)$", line) m = re.match(r"cache.hit\D*(\d+)$", line)
if m is not None: if m is not None:
hits += int(m.group(1)) hits += int(m.group(1))
m = re.match(r"cache.miss\D*(\d+)", line) m = re.match(r"cache.miss\D*(\d+)", line)
if m is not None: if m is not None:
miss += int(m.group(1)) 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) return (hits, miss)
@ -35,6 +48,11 @@ def build_board(boardname):
subprocess.run(["./waf", "clean", "copter"]) 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(",") boards = args.boards.split(",")
if len(boards) != 2: if len(boards) != 2:
print(boards) print(boards)
@ -42,6 +60,7 @@ if len(boards) != 2:
sys.exit(1) sys.exit(1)
os.environ['CCACHE_DIR'] = os.path.join(os.getcwd(), 'build', 'ccache') os.environ['CCACHE_DIR'] = os.path.join(os.getcwd(), 'build', 'ccache')
subprocess.run(["ccache", "--version"])
subprocess.run(["ccache", "-C", "-z"]) subprocess.run(["ccache", "-C", "-z"])
build_board(boards[0]) build_board(boards[0])
subprocess.run(["ccache", "-z"]) subprocess.run(["ccache", "-z"])