Skip to content

Commit

Permalink
Tools: fixed ccache test for newer ccache version
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge authored and peterbarker committed Nov 7, 2023
1 parent 2d1a8a2 commit 8d43afd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Tools/scripts/build_tests/test_ccache.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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()

Expand All @@ -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)


Expand All @@ -35,13 +48,19 @@ 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)
print("Must specify exactly 2 boards (comma separated)")
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"])
Expand Down

0 comments on commit 8d43afd

Please sign in to comment.