Skip to content

Commit

Permalink
[2024/11] add --cache_info script arg, to output cache hits & misses
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlitGhost committed Dec 11, 2024
1 parent a997dd8 commit b2cc89a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions 2024/11/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

aoc.argparser.add_argument("-n", "--num_blinks", default=0, type=int,
help="number of times to blink")
aoc.argparser.add_argument("-c", "--cache_info", action="store_true",
help="output cache info")


@cache
Expand Down Expand Up @@ -55,14 +57,29 @@ def main():
if aoc.args.num_blinks > 0:
stones = blink_n_times(start_stones, aoc.args.num_blinks)
print(f"{aoc.args.num_blinks} blinks: {sum(stones.values())}")

if aoc.args.cache_info:
print(f"num_digits: {num_digits.cache_info().hits} hits, {num_digits.cache_info().misses} misses")
print(f"split: {split.cache_info().hits} hits, {split.cache_info().misses} misses")

exit(0)

stones = blink_n_times(start_stones, 25)
print(f"p1: {sum(stones.values())}")

if aoc.args.cache_info:
print(f"num_digits: {num_digits.cache_info().hits} hits, {num_digits.cache_info().misses} misses")
print(f"split: {split.cache_info().hits} hits, {split.cache_info().misses} misses")
num_digits.cache_clear()
split.cache_clear()

stones = blink_n_times(start_stones, 75)
print(f"p2: {sum(stones.values())}")

if aoc.args.cache_info:
print(f"num_digits: {num_digits.cache_info().hits} hits, {num_digits.cache_info().misses} misses")
print(f"split: {split.cache_info().hits} hits, {split.cache_info().misses} misses")


if __name__ == "__main__":
main()

0 comments on commit b2cc89a

Please sign in to comment.