Created
February 16, 2023 20:02
-
-
Save jmdelaney8/1d7cca8dc6ccc7bba0894eb358729591 to your computer and use it in GitHub Desktop.
test if bistruct.c.compile has a memory leak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import tracemalloc | |
import bitstruct | |
STAT_PERIOD = 5 # seconds | |
little_fmt = 'u24' | |
names=['requested_pgn'] | |
start = time.perf_counter() | |
prev_stat_time = time.perf_counter() | |
prev_snapshot = tracemalloc.take_snapshot() | |
tracemalloc.start() | |
while True: | |
if time.perf_counter() - prev_stat_time > STAT_PERIOD: | |
snapshot = tracemalloc.take_snapshot() | |
top_stats = snapshot.compare_to(prev_snapshot, 'lineno') | |
print(f"\nrun time: {round(time.perf_counter() -start)} seconds") | |
print(f"[ Top 10 differences:]") | |
for stat in top_stats[:10]: | |
print(stat) | |
prev_snapshot = snapshot | |
prev_stat_time = time.perf_counter() | |
bitstruct.c.compile(little_fmt, names) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment