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.

Returns the computed memory statistics for a single value using a specific DataSizeEstimator.

Returns the computed memory statistics for a collection of values.

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.

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.

Returns the estimated total size of the given value using a specific DataSizeEstimator.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

The resulting type after applying the * operator.

Performs the * operation. 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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

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

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

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

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Compare self to key and return true if they are equal.

Performs the conversion.

Creates Self using data from the given MemoryConfig.

Creates Self using data from the given [World]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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