aegis_sim.utilities.funcs
1import time 2import logging 3 4from aegis_sim import variables 5from aegis_sim.parameterization import parametermanager 6 7 8# Decorators 9def profile_time(func): 10 def wrapper(*args, **kwargs): 11 start_time = time.time() 12 result = func(*args, **kwargs) 13 end_time = time.time() 14 execution_time = (end_time - start_time) * 1000 15 logging.info(f"{func.__name__} took {execution_time:.6f} ms to execute") 16 return result 17 18 return wrapper 19 20 21def skip(rate_name) -> bool: 22 """Should you skip an action performed at a certain rate""" 23 24 rate = getattr(parametermanager.parameters, rate_name) 25 26 # Skip if rate deactivated 27 if rate <= 0: 28 return True 29 30 # Do not skip first step 31 if variables.steps == 1: 32 return False 33 34 # Skip unless step is divisible by rate 35 return variables.steps % rate > 0 36 37 38def steps_to_end() -> int: 39 return parametermanager.parameters.STEPS_PER_SIMULATION - variables.steps
def
profile_time(func):
10def profile_time(func): 11 def wrapper(*args, **kwargs): 12 start_time = time.time() 13 result = func(*args, **kwargs) 14 end_time = time.time() 15 execution_time = (end_time - start_time) * 1000 16 logging.info(f"{func.__name__} took {execution_time:.6f} ms to execute") 17 return result 18 19 return wrapper
def
skip(rate_name) -> bool:
22def skip(rate_name) -> bool: 23 """Should you skip an action performed at a certain rate""" 24 25 rate = getattr(parametermanager.parameters, rate_name) 26 27 # Skip if rate deactivated 28 if rate <= 0: 29 return True 30 31 # Do not skip first step 32 if variables.steps == 1: 33 return False 34 35 # Skip unless step is divisible by rate 36 return variables.steps % rate > 0
Should you skip an action performed at a certain rate
def
steps_to_end() -> int: