File size: 678 Bytes
2862b00
2386a1a
2862b00
 
2386a1a
2862b00
2386a1a
2862b00
 
 
 
2386a1a
2862b00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
Monitoring utilities for tracking execution timing.
"""

from dataclasses import dataclass

__all__ = ["Timing"]


@dataclass
class Timing:
    """Timing information for a step or run."""

    start_time: float
    end_time: float | None = None

    @property
    def duration(self):
        return None if self.end_time is None else self.end_time - self.start_time

    def dict(self):
        return {
            "start_time": self.start_time,
            "end_time": self.end_time,
            "duration": self.duration,
        }

    def __repr__(self) -> str:
        return f"Timing(start_time={self.start_time}, end_time={self.end_time}, duration={self.duration})"