from dataclasses import dataclass, field from typing import Dict @dataclass class CacheStats(object): """Collect statistics on cache performance.""" hits: int = 0 # cache hits misses: int = 0 # cache misses high_watermark: int = 0 # amount of cache used in_cache: int = 0 # number of models in cache cleared: int = 0 # number of models cleared to make space cache_size: int = 0 # total size of cache loaded_model_sizes: Dict[str, int] = field(default_factory=dict)