# Efficiently creating and updating a struct of SVectors

**URL:** <https://discourse.julialang.org/t/efficiently-creating-and-updating-a-struct-of-svectors/119697>\
**Category:** Performance\
**Tags:** struct, staticarrays, setfield, accessors\
**Created:** [September 22, 2024, 3:44pm UTC](https://discourse.julialang.org/t/efficiently-creating-and-updating-a-struct-of-svectors/119697 "2024-09-22T15:44:12Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![Tetrakai](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@Tetrakai](https://discourse.julialang.org/u/Tetrakai)\
**Post date:** [September 23, 2024, 7:58pm UTC](https://discourse.julialang.org/t/efficiently-creating-and-updating-a-struct-of-svectors/119697/11 "2024-09-23T19:58:17Z")

</div>

I see the same as you on my laptop (Intel i5-6300u running julia 1.10.4 with default optimization), but on pc (AMD 2990wx running julia 1.11.0-rc1 with -O3 flag) all three of those are ~ equally fast.

I saw this same thing earlier here:

> [@SVectors + @reset from Accessors: Strange Benchmarks](https://discourse.julialang.org/t/svectors-reset-from-accessors-strange-benchmarks/119201/24):
>
> If we get rid of the random number, can’t the compiler just calculate the result? I think that is what I am seeing when I make it simpler. Results differ on my PC vs laptop (which are also different Julia versions…) and depending on the optimization flag. 
> 
> > **Slimmed MWE**
> >
> > using Parameters, StaticArrays, Accessors, BenchmarkTools using Distributions, Random @with\_kw struct Str00{N} fat :: SVector{N, Float64} sh\_c0 :: SVector{N, Float64} sh\_cm :: SVector{N, Float64} end Random.seed!(…

---

_[View the full topic](https://discourse.julialang.org/t/efficiently-creating-and-updating-a-struct-of-svectors/119697)._
