-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change StorageMemoryUsage type from struct to enum #219
Conversation
Thanks for putting this together! What do you think of something like this? pub trait MemoryUsage {
type Out;
fn detailed_memory_usage(&self) -> Self::Out;
}
Does this make sense? Do you think it would also be too verbose? |
Sorry for the late confirmation. |
I implemented it based on the ideas you provided. I also thought about the type names and field names, but if you have any better naming suggestions, please revise them. I'm not sure which parts of Entities should be subdivided to help with debugging, so I left it as is. Here’s an example output of the newly added SparseSet’s detailed_memory_usage: |
src/sparse_set/mod.rs
Outdated
@@ -1437,4 +1504,129 @@ mod tests { | |||
|
|||
assert_eq!(memory_usage.used_memory_bytes, expected_total_memory); | |||
} | |||
|
|||
/// Verifies that the `detailed_memory_usage` method accurately reflects the current `SparseSet` data breakdown. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for writing a test!
Thanks for the update!
No worries, there's no rush.
I don't have a better idea right now. To understand this information, people need some understanding of
Now that I look at it yeah I don't know what more there is to add. |
@leudz
As mentioned earlier, I attempted to convert the StorageMemoryUsage type into a trait. The first approach involved defining an Out type for each Storage type that implements the StorageMemoryUsage trait, allowing the memory_usage function to return an Option<Box> type. The second approach was to add StorageMemoryUsage as an associated trait to the Storage trait. The first approach felt overly verbose, and the second required too extensive code changes, so I opted for a simpler solution by handling it as an enum to enable more detailed information during debugging. If there are any suggested modifications, please let me know.