test api: class for ioclass usage stats
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
parent
6cbce57106
commit
0e1ba12756
@ -15,6 +15,7 @@ config_stats_core = [
|
|||||||
]
|
]
|
||||||
config_stats_ioclass = ["io class id", "io class name", "eviction priority", "selective allocation"]
|
config_stats_ioclass = ["io class id", "io class name", "eviction priority", "selective allocation"]
|
||||||
usage_stats = ["occupancy", "free", "clean", "dirty"]
|
usage_stats = ["occupancy", "free", "clean", "dirty"]
|
||||||
|
usage_stats_ioclass = ["occupancy", "clean", "dirty"]
|
||||||
inactive_usage_stats = ["inactive occupancy", "inactive clean", "inactive dirty"]
|
inactive_usage_stats = ["inactive occupancy", "inactive clean", "inactive dirty"]
|
||||||
request_stats = [
|
request_stats = [
|
||||||
"read hits", "read partial misses", "read full misses", "read total",
|
"read hits", "read partial misses", "read full misses", "read total",
|
||||||
@ -175,8 +176,8 @@ class IoClassStats:
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.usage_stats = UsageStats(
|
self.usage_stats = IoClassUsageStats(
|
||||||
*[stats[stat] for stat in usage_stats]
|
*[stats[stat] for stat in usage_stats_ioclass]
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
@ -419,6 +420,49 @@ class UsageStats:
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
|
class IoClassUsageStats:
|
||||||
|
def __init__(self, occupancy, clean, dirty):
|
||||||
|
self.occupancy = occupancy
|
||||||
|
self.clean = clean
|
||||||
|
self.dirty = dirty
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return (
|
||||||
|
f"Usage stats:\n"
|
||||||
|
f"Occupancy: {self.occupancy}\n"
|
||||||
|
f"Clean: {self.clean}\n"
|
||||||
|
f"Dirty: {self.dirty}\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return str(self)
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
if not other:
|
||||||
|
return False
|
||||||
|
return (
|
||||||
|
self.occupancy == other.occupancy
|
||||||
|
and self.clean == other.clean
|
||||||
|
and self.dirty == other.dirty
|
||||||
|
)
|
||||||
|
|
||||||
|
def __ne__(self, other):
|
||||||
|
return not self == other
|
||||||
|
|
||||||
|
def __add__(self, other):
|
||||||
|
return UsageStats(
|
||||||
|
self.occupancy + other.occupancy,
|
||||||
|
self.clean + other.clean,
|
||||||
|
self.dirty + other.dirty
|
||||||
|
)
|
||||||
|
|
||||||
|
def __iadd__(self, other):
|
||||||
|
self.occupancy += other.occupancy
|
||||||
|
self.clean += other.clean
|
||||||
|
self.dirty += other.dirty
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
class InactiveUsageStats:
|
class InactiveUsageStats:
|
||||||
def __init__(self, inactive_occupancy, inactive_clean, inactive_dirty):
|
def __init__(self, inactive_occupancy, inactive_clean, inactive_dirty):
|
||||||
self.inactive_occupancy = inactive_occupancy
|
self.inactive_occupancy = inactive_occupancy
|
||||||
|
Loading…
Reference in New Issue
Block a user