don't leak memory in global table unless we want to record performance
This commit is contained in:
@@ -71,8 +71,6 @@ class TimeTable:
|
||||
weakref.finalize(self, self.table_print)
|
||||
|
||||
def table_print(self) -> None:
|
||||
if os.getenv("PERF") != "1":
|
||||
return
|
||||
print("======== CMD TIMETABLE ========")
|
||||
|
||||
# Sort the table by time in descending order
|
||||
@@ -96,6 +94,8 @@ class TimeTable:
|
||||
self.table[cmd] = time
|
||||
|
||||
|
||||
TIME_TABLE = None
|
||||
if os.environ.get("CLAN_CLI_PERF"):
|
||||
TIME_TABLE = TimeTable()
|
||||
|
||||
|
||||
@@ -136,6 +136,7 @@ def run(
|
||||
tend = datetime.datetime.now(tz=datetime.UTC)
|
||||
|
||||
global TIME_TABLE
|
||||
if TIME_TABLE:
|
||||
TIME_TABLE.add(shlex.join(cmd), tend - tstart)
|
||||
|
||||
# Wait for the subprocess to finish
|
||||
|
||||
Reference in New Issue
Block a user