Switch to a single view indicating current usage

This commit is contained in:
Louis Dureuil 2024-01-23 13:03:30 +01:00
parent 256538ccb9
commit cc79cd0b04
No known key found for this signature in database
2 changed files with 20 additions and 46 deletions

View file

@ -133,6 +133,14 @@ impl MemoryStats {
bytes_reallocated: self.bytes_reallocated.checked_sub(other.bytes_reallocated)?,
})
}
pub fn usage(&self) -> isize {
(self.bytes_allocated - self.bytes_deallocated) as isize + self.bytes_reallocated
}
pub fn operations(&self) -> usize {
self.allocations + self.deallocations + self.reallocations
}
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]