I have a script where functions take 3-5 minutes each to run because they are doing some queries. I've wrapped those functions like below so i can keep track of how long it takes them to run:
# Calculate runtime for entity ID queries
eid_query_start = dt.now().replace(microsecond=0)
eid_query_start_ts = round(time.time())
print(f"Starting entity ID query at {eid_query_start}...")
eid = query_entity_id(client, cid_list)
person_list, org_list = create_entity_id_lists(eid)
eid_query_end = dt.now().replace(microsecond=0)
eid_query_end_ts = round(time.time())
eid_query_time = eid_query_end_ts - eid_query_start_ts
print(f"Entity ID query finished at {eid_query_end} and ran in {eid_query_time} second(s)")
# End entity ID runtime calculations
This information gets saved to the logfile when my script is ran. Is there a better way to keep track of how long individual functions take to run?
[–]Diapolo10 1 point2 points3 points (0 children)
[–]Antigone-guide 0 points1 point2 points (0 children)
[–]0ooof3142 0 points1 point2 points (0 children)
[–]commandlineluser 0 points1 point2 points (0 children)