Understanding vec vs boxed slice performance

PressRex profile image
by PressRex
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

Read full topic

Source: View source

PressRex profile image
by PressRex

Subscribe to New Posts

Lorem ultrices malesuada sapien amet pulvinar quis. Feugiat etiam ullamcorper pharetra vitae nibh enim vel.

Success! Now Check Your Email

To complete Subscribe, click the confirmation link in your inbox. If it doesn’t arrive within 3 minutes, check your spam folder.

Ok, Thanks

Read More