mendevi.measures.Activity¶
- class mendevi.measures.Activity(sleep: Real = 0.05)[source]¶
Measure the computer activity of a section.
Examples¶
>>> import pprint, time >>> from mendevi.measures import Activity >>> with Activity() as activity: ... time.sleep(0.1) ... activity.start_slice("lbl 1") ... time.sleep(0.2) ... _ = activity.stop_slice() ... activity.start_slice("lbl 2") ... time.sleep(0.3) ... activity.start_slice("lbl 3") ... time.sleep(0.4) ... >>> slices, full = activity.get_slices(), activity.get_full() >>> round(full["duration"], 2) 1.0 >>> sorted(slices) ['lbl 1', 'lbl 2', 'lbl 3'] >>> round(slices["lbl 2"]["duration"], 2) 0.3 >>>
Init the perf context.
Parameters¶
- sleepfloat, default=50e-3
The time interval between 2 measures (in s).
- get_full() dict | tuple[dict, dict][source]¶
Collect the data and return the full activity.
Returns¶
- activity: dict[str]
duration: float, the real measure duration.
gpu_core: list[list[float]], tensor of detailed usage of each GPU in [0, 1].
gpu_core_avg: float, the sum of the average usage of each GPU.
gpu_dt: list[float], the duration of each interval (in s).
gpu_power: list[list[float]], the sampled power in each point (in W).
gpu_power_avg: float, the total power consumption of all GPU (in W).
ps_core: list[list[float]], tensor of detailed usage of each logical core in %.
ps_core_avg: float, the mean cummulated usage of all the logical cpus.
ps_dt: list[float], the duration of each interval (in s).
ps_ram: list[int], list of the sampled ram usage in bytes in each point.
ps_ram_avg: float, the average ram usage in bytes in each point.
ps_temp: dict[str, list[float]], the temperature of each device (in C).
ps_temp_avg: dict[str, float], the average temperature of each device (in C).
rapl_dt: list[float], the duration of each interval (in s).
rapl_power: list[float], the average power in each interval (in W).
rapl_power_avg: float, the average power, energy divided by the duration (in W).
start: float, absolute timestamp.
wattmeter_dt: list[float], the duration of each interval (in s).
wattmeter_power: list[float], the sampled power in watt in each point.
wattmeter_power_avg: float, the average power, energy divided by the duration (in W).
- get_slices() dict[str, dict][source]¶
For each slices initialized by start_slice, are returned here.
Returns¶
- slicesdict[str, dict]
For each label given in
start_slice, return the same dict asget_full()for this specific slice.
- start_slice(lbl: Hashable) None[source]¶
Add a new named slice of activity.
Parameters¶
- lblhashable
The section name, as a key of the final dictionay. If it is called several times, the slice with the same label are concatenated.
Notes¶
If this method is never called, the final result will not be pack into a dict.