11 releases
0.1.10 | Nov 4, 2024 |
---|---|
0.1.9 | Sep 7, 2024 |
0.1.8 | Aug 27, 2024 |
0.1.7 | Apr 2, 2024 |
0.1.3 | Nov 29, 2023 |
#419 in Development tools
96,426 downloads per month
Used in 11 crates
(6 directly)
39KB
799 lines
TypeSize
A library to fetch an accurate estimate of the total memory usage of a value.
See the documentation on docs.rs.
lib.rs
:
Typesize
A library to fetch an accurate estimate of the total memory usage of a value.
The goal of this library is to produce the most accurate estimate possible, however without being deeply
integrated into the entire ecosystem this cannot be possible. This leads to the real goal being to get
"close enough" for getting a sense of memory usage in your program. If one of the TypeSize
implementations built-in could be improved, a PR would be greatly appreciated.
An example usage of this library would be to wrap all the types you want to measure recursively in
the derive::TypeSize
derive macro, and for any types which perform their own heap allocation
to manually implement TypeSize
while overriding the TypeSize::extra_size
method.
MSRV
The Minimum Supported Rust Version is of this crate is 1.65, and it is considered breaking to raise this.
This is without any library support features, as those libraries may require a higher MSRV.
Features
std
: ImplementsTypeSize
forHashMap
andHashSet
, default enabled.details
: AddsTypeSize::get_size_details
andTypeSize::get_collection_item_count
to get field by field breakdowns of struct types.
Library Support
dashmap
: ImplementsTypeSize
forDashMap
(Only5.x
, use thetypesize
feature of dashmap for6.1
+).arrayvec
: ImplementsTypeSize
forArrayVec
andArrayString
of any size.simd_json
: ImplementsTypeSize
forOwnedValue
andStaticNode
, enables halfbrown.halfbrown
: ImplementsTypeSize
forSizedHashMap
, enables hashbrown.extract_map_01
: ImplementsTypeSize
forextract_map::ExtractMap
.parking_lot
: ImplementsTypeSize
forparking_lot::Mutex
andparking_lot::RwLock
.serde_json
: ImplementsTypeSize
forserde_json::Value
andserde_json::Map
.mini_moka
: ImplementsTypeSize
formini_moka::unsync::Cache
, andmini_moka::sync::Cache
ifdashmap
is enabled.hashbrown
: ImplementsTypeSize
forhashbrown::HashMap
.secrecy
: ImplementsTypeSize
forSecret
.chrono
: ImplementsTypeSize
forchrono::DateTime
of anychrono::TimeZone
.nonmax
: ImplementsTypeSize
for allnonmax
types.time
: ImplementsTypeSize
fortime::OffsetDateTime
.url
: ImplementsTypeSize
forurl::Url
.bitvec
: ImplementsTypeSize
forbitvec::array::BitArray
andbitvec::vec::BitVec
.web-time
: ImplementsTypeSize
forweb_time::Instant
andweb_time::SystemTime
(on platforms where these aren't type aliases tostd::time
types).
Dependencies
~0.2–8MB
~71K SLoC