don't leak memory in global table unless we want to record performance

This commit is contained in:
Jörg Thalheim
2024-10-01 19:30:34 +02:00
parent d5d6774124
commit 46c0b7cb2e

View File

@@ -71,8 +71,6 @@ class TimeTable:
weakref.finalize(self, self.table_print) weakref.finalize(self, self.table_print)
def table_print(self) -> None: def table_print(self) -> None:
if os.getenv("PERF") != "1":
return
print("======== CMD TIMETABLE ========") print("======== CMD TIMETABLE ========")
# Sort the table by time in descending order # Sort the table by time in descending order
@@ -96,7 +94,9 @@ class TimeTable:
self.table[cmd] = time self.table[cmd] = time
TIME_TABLE = TimeTable() TIME_TABLE = None
if os.environ.get("CLAN_CLI_PERF"):
TIME_TABLE = TimeTable()
def run( def run(
@@ -136,6 +136,7 @@ def run(
tend = datetime.datetime.now(tz=datetime.UTC) tend = datetime.datetime.now(tz=datetime.UTC)
global TIME_TABLE global TIME_TABLE
if TIME_TABLE:
TIME_TABLE.add(shlex.join(cmd), tend - tstart) TIME_TABLE.add(shlex.join(cmd), tend - tstart)
# Wait for the subprocess to finish # Wait for the subprocess to finish