Struct bevy_datasize::MemoryStats [−][src]
pub struct MemoryStats {
pub count: usize,
pub total_stack_bytes: usize,
pub total_heap_bytes: usize,
}
Expand description
Memory usage statistics for a single data type.
Example
#[derive(DataSize)]
struct SomeData {
data: Vec<u8>,
}
assert_eq!(std::mem::size_of::<SomeData>(), 24);
let values = vec![
SomeData { data: vec![0; 100] },
SomeData { data: vec![0; 100] },
];
let stats = MemoryStats::from_values(values.iter());
assert_eq!(stats.count, 2);
assert_eq!(stats.total_stack_bytes, 48);
assert_eq!(stats.total_heap_bytes, 200);
assert_eq!(stats.total_bytes(), 248);
assert_eq!(format!("{stats}"), "2 (248 B)")
Fields
count: usize
The total number of instances of this data type.
total_stack_bytes: usize
The total number of “stack” bytes used by instances of this data type.
See stack_size_of
for details on the meaning of this quantity.
total_heap_bytes: usize
The estimated total number of bytes used by instances of this data type.
See heap_size_of
for details on the meaning of this quantity.
Implementations
Returns the sum of total_stack_bytes
and total_heap_bytes
for
self
.
Returns the computed memory statistics for a single value.
pub fn from_value_with_estimator<T, E>(value: &T, estimator: &E) -> Self where
T: Any,
E: DataSizeEstimator<T>,
pub fn from_value_with_estimator<T, E>(value: &T, estimator: &E) -> Self where
T: Any,
E: DataSizeEstimator<T>,
Returns the computed memory statistics for a single value using a
specific DataSizeEstimator
.
pub fn from_values<'a, T, I>(values: I) -> Self where
T: Any + DataSize,
I: IntoIterator<Item = &'a T>,
pub fn from_values<'a, T, I>(values: I) -> Self where
T: Any + DataSize,
I: IntoIterator<Item = &'a T>,
Returns the computed memory statistics for a collection of values.
pub fn from_values_with_estimator<'a, T, E, I>(values: I, estimator: &E) -> Self where
T: Any,
E: DataSizeEstimator<T>,
I: IntoIterator<Item = &'a T>,
pub fn from_values_with_estimator<'a, T, E, I>(values: I, estimator: &E) -> Self where
T: Any,
E: DataSizeEstimator<T>,
I: IntoIterator<Item = &'a T>,
Returns the computed memory statistics for a collection of values.
Returns the “stack” size of the given value.
This quantity represents how many bytes the type would take up on the stack if were allocated there.
This quantity is exact and is computed using std::mem::size_of
.
Returns the estimated heap size of the given value.
This quantity represents how many bytes the type occupies apart from the immediate bytes of its fields.
This quantity is estimated and may not be 100% accurate for all types.
pub fn heap_size_of_with_estimator<T, E>(value: &T, estimator: &E) -> usize where
E: DataSizeEstimator<T>,
pub fn heap_size_of_with_estimator<T, E>(value: &T, estimator: &E) -> usize where
E: DataSizeEstimator<T>,
Returns the estimated heap size of the given value using a specific
DataSizeEstimator
.
Returns the estimated total size of the given value.
This quantity is the sum of stack_size_of
and heap_size_of
.
pub fn total_size_of_with_estimator<T, E>(value: &T, estimator: &E) -> usize where
T: Any,
E: DataSizeEstimator<T>,
pub fn total_size_of_with_estimator<T, E>(value: &T, estimator: &E) -> usize where
T: Any,
E: DataSizeEstimator<T>,
Returns the estimated total size of the given value using a specific
DataSizeEstimator
.
Trait Implementations
Returns the “default value” for a type. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for MemoryStats
impl Send for MemoryStats
impl Sync for MemoryStats
impl Unpin for MemoryStats
impl UnwindSafe for MemoryStats
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
impl<T> DynHash for T where
T: DynEq + Hash,
impl<T> DynHash for T where
T: DynEq + Hash,
Compare self to key
and return true
if they are equal.
Creates Self
using data from the given MemoryConfig
.
impl<T> FromWorld for T where
T: Default,
impl<T> FromWorld for T where
T: Default,
pub fn from_world(_world: &mut World) -> T
pub fn from_world(_world: &mut World) -> T
Creates Self
using data from the given [World]
pub fn clone_type_data(&self) -> Box<dyn TypeData + 'static, Global>
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more