|
| 1 | +"""helpers for the simulation""" |
| 2 | + |
| 3 | +from collections.abc import Iterable |
| 4 | + |
| 5 | +from app.config.constants import EventMetricName, SampledMetricName |
| 6 | + |
| 7 | + |
| 8 | +def alloc_sample_metric( |
| 9 | + enabled_sample_metrics: Iterable[SampledMetricName], |
| 10 | + ) -> dict[str, list[float | int]]: |
| 11 | + """ |
| 12 | + After the pydantic validation of the whole input we |
| 13 | + instantiate a dictionary to collect the sampled metrics the |
| 14 | + user want to measure |
| 15 | + """ |
| 16 | + # t is the alignmente parameter for example assume |
| 17 | + # the snapshot for the sampled metrics are done every 10ms |
| 18 | + # t = [10,20,30,40....] to each t will correspond a measured |
| 19 | + # metric corresponding to that time interval |
| 20 | + |
| 21 | + dict_sampled_metrics: dict[str, list[float | int]] = {"t": []} |
| 22 | + for key in enabled_sample_metrics: |
| 23 | + dict_sampled_metrics[key] = [] |
| 24 | + return dict_sampled_metrics |
| 25 | + |
| 26 | + |
| 27 | +def alloc_event_metric( |
| 28 | + enabled_event_metrics: Iterable[EventMetricName], |
| 29 | + ) -> dict[str, list[float | int]]: |
| 30 | + """ |
| 31 | + After the pydantic validation of the whole input we |
| 32 | + instantiate a dictionary to collect the event metrics the |
| 33 | + user want to measure |
| 34 | + """ |
| 35 | + dict_event_metrics: dict[str, list[float | int]] = {} |
| 36 | + for key in enabled_event_metrics: |
| 37 | + dict_event_metrics[key] = [] |
| 38 | + return dict_event_metrics |
0 commit comments