Some serialize, deserialize tests.
rkyv is by far the winner, it's pretty much on par with manual deserialization by hand.
35.2% 88.8% 2.8KiB [Unknown] deserialize_package_config
1.2% 3.1% 100B alloc alloc::slice::<impl alloc::borrow::ToOwned for [T]>::to_owned
0.7% 1.7% 54B [Unknown] __rust_alloc
0.0% 0.0% 1B std std::sys::pal::unix::args::imp::ARGV_INIT_ARRAY::init_wrapper
0.0% 0.0% 0B And 0 smaller methods. Use -n N to show more.
39.7% 100.0% 3.2KiB .text section size, the file size is 8.0KiB
Other solutions, often based on serde introduce additional code bloat. This is unfortunately not always serde's fault, but just something that happens.
Example:
Postcard:
39.0% 68.2% 5.6KiB [Unknown] deserialize_package_config
4.5% 7.8% 657B serde serde::de::impls::<impl serde::de::Deserialize for alloc::string::String>::deserialize
4.2% 7.3% 615B serde serde::de::SeqAccess::next_element
1.4% 2.5% 213B alloc alloc::raw_vec::finish_grow
1.3% 2.2% 185B alloc alloc::raw_vec::RawVec<T,A>::grow_one
1.3% 2.2% 185B alloc alloc::raw_vec::RawVec<T,A>::grow_one
1.3% 2.2% 184B alloc alloc::raw_vec::RawVec<T,A>::grow_one
1.0% 1.8% 152B core core::ptr::drop_in_place<alloc::vec::Vec<postcard_test::Credit>>
0.9% 1.5% 126B core core::ptr::drop_in_place<alloc::vec::Vec<postcard_test::DependencyInfo>>
0.6% 1.1% 94B core core::ptr::drop_in_place<alloc::vec::Vec<alloc::string::String>>
0.4% 0.6% 54B [Unknown] __rust_alloc
0.0% 0.0% 1B std std::sys::pal::unix::args::imp::ARGV_INIT_ARRAY::init_wrapper
0.0% 0.0% 0B And 0 smaller methods. Use -n N to show more.
57.2% 100.0% 8.2KiB .text section size, the file size is 14.4KiB
Manual (Unoptimized):
21.7% 55.0% 2.1KiB [Unknown] deserialize_package_config
6.4% 16.2% 633B postcard_test postcard_test::deserialize_string
2.2% 5.5% 213B alloc alloc::raw_vec::finish_grow
1.9% 4.7% 185B alloc alloc::raw_vec::RawVec<T,A>::grow_one
1.9% 4.7% 185B alloc alloc::raw_vec::RawVec<T,A>::grow_one
1.9% 4.7% 184B alloc alloc::raw_vec::RawVec<T,A>::grow_one
0.9% 2.3% 89B postcard_test postcard_test::deserialize_option_string
0.5% 1.4% 54B [Unknown] __rust_alloc
0.0% 0.0% 1B std std::sys::pal::unix::args::imp::ARGV_INIT_ARRAY::init_wrapper
0.0% 0.0% 0B And 0 smaller methods. Use -n N to show more.
39.5% 100.0% 3.8KiB .text section size, the file size is 9.6KiB
With optimization, should pretty much match rkyv; but with copying.
Git Repo with Random Lib Tests Wiki Version with Extra Details
Some serialize, deserialize tests. rkyv is by far the winner, it's pretty much on par with manual deserialization by hand.
Other solutions, often based on serde introduce additional code bloat. This is unfortunately not always serde's fault, but just something that happens.
Example:
Postcard:
Manual (Unoptimized):
With optimization, should pretty much match rkyv; but with copying.
Bincode:
Bitcode: