Understanding vec vs boxed slice performance
I have a scenario where I will like to continuously read and write to a fixed sized array (where size is not known at compile time).
As far as I'm aware, this is usually represented as a Box[T]>
or Vec<T>
, where the main difference between them is the existence of the capacity field and resizing methods on the vec.
I wasn't expecting any significant performance differences, but some example code I wrote seemed to indicate that boxed slices are somehow significantly faster (see playground). How do we explain this behavior?
2 posts - 2 participants
Source: View source