Skip to content

TimeLogger

logger = get_logger(__name__) module-attribute

For the latency

If it is model, the name will start with model_xx, and it is a duration If it is transfer time, the name will start with transfer_xx, and it is a duration If it is just to log the timestamp, the name will start with ts_xx, and it is a timestamp

TimeLogger

Source code in Agent/utils/time_logger.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class TimeLogger:

    @staticmethod
    def log_task(task: Task, name: str):
        """
        Log the time taken to execute a block of code
        Args:
            task (Task): The task to store the time
            name (str): The name of the block

        Returns:

        """
        # check whether the task has the latency profile

        TimeLogger.log(task.result_json.latency_profile, name)

    @staticmethod
    def log(profile: dict, name: str):
        """
        Log the time taken to execute a block of code
        Args:
            profile (dict): The profile to store the time
            name (str): The name of the block

        Returns:

        """
        logger.info(profile)
        logger.info(name)
        profile[f"ts_{name}"] = datetime.now()

log(profile, name) staticmethod

Log the time taken to execute a block of code Args: profile (dict): The profile to store the time name (str): The name of the block

Returns:

Source code in Agent/utils/time_logger.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
@staticmethod
def log(profile: dict, name: str):
    """
    Log the time taken to execute a block of code
    Args:
        profile (dict): The profile to store the time
        name (str): The name of the block

    Returns:

    """
    logger.info(profile)
    logger.info(name)
    profile[f"ts_{name}"] = datetime.now()

log_task(task, name) staticmethod

Log the time taken to execute a block of code Args: task (Task): The task to store the time name (str): The name of the block

Returns:

Source code in Agent/utils/time_logger.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@staticmethod
def log_task(task: Task, name: str):
    """
    Log the time taken to execute a block of code
    Args:
        task (Task): The task to store the time
        name (str): The name of the block

    Returns:

    """
    # check whether the task has the latency profile

    TimeLogger.log(task.result_json.latency_profile, name)