# Performance disadvantages of structs?

**URL:** https://discourse.julialang.org/t/performance-disadvantages-of-structs/57397
**Category:** New to Julia
**Created:** [March 17, 2021, 5:13pm UTC](https://discourse.julialang.org/t/performance-disadvantages-of-structs/57397 "2021-03-17T17:13:06Z")
**Posts on this page:** 1
**Showing post:** 17

<div class="post-metadata">

### Author: ![Ribeiro](https://avatars.discourse-cdn.com/v4/letter/r/d9b06d/32.png) [@Ribeiro](https://discourse.julialang.org/u/Ribeiro)
#### Post date: [March 18, 2021, 7:11pm UTC](https://discourse.julialang.org/t/performance-disadvantages-of-structs/57397/17 "2021-03-18T19:11:29Z")

</div>

Alright, so I did some basic testing. Seems mutable or not makes only a tiny difference in my case (within repeatability). However, defining one of my vectors as  
`Vector{StaticArrays.SVector{3,Int}}`  
vs  
`Vector{Union{ StaticArrays.SVector{3,Int},StaticArrays.SVector{4,Int} }}`  
or  
`Array{SArray{S,Int64,1,L} where L where S<:Tuple,1}`  
makes quite the difference (20-30% for the first, 2x for the second). The discussion on these definitions is here [Struct variables explicit setting](https://discourse.julialang.org/t/struct-variables-explicit-setting/57396) so I got some tips already.  
So other than my crappy way of defining my variables, structs seem ok (and the same as passing vectors). I’ll still have to figure out how I can have a Vector with SArrays that can be 3 or 4 elements long.  
Thanks, everyone.

---

_[View the full topic](https://discourse.julialang.org/t/performance-disadvantages-of-structs/57397)._
