# SVectors + @reset from Accessors: Strange Benchmarks

**URL:** <https://discourse.julialang.org/t/svectors-reset-from-accessors-strange-benchmarks/119201>\
**Category:** General Usage\
**Tags:** benchmarktools, staticarrays, setfield, accessors\
**Created:** [September 9, 2024, 2:50am UTC](https://discourse.julialang.org/t/svectors-reset-from-accessors-strange-benchmarks/119201 "2024-09-09T02:50:02Z")\
**Posts on this page:** 1\
**Showing post:** 8

<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 9, 2024, 5:07pm UTC](https://discourse.julialang.org/t/svectors-reset-from-accessors-strange-benchmarks/119201/8 "2024-09-09T17:07:39Z")

</div>

Eg, here is one actual loop this would be used on. Something like `@Unroll_before_reset` would be ideal:

```julia
function test6(gt)
    for t in 1:10
       @Unroll_before_reset for i in 1:2
            @reset gt[i].min .+= gt[i].act

            r1 = @SVector rand(Uniform(-.003, .003), 16)
            @reset gt[i].fat .-= gt[i].act .* (gt[i].ded .- r1)
            @reset gt[i].fat .= max.(gt[i].fat, 0.1)

            @reset gt[i].sh_cm .= gt[i].sh_c0 .* gt[i].fat .* gt[i].act
            @reset gt[i].ps_cm .= gt[i].ps_c0 .* gt[i].fat .* gt[i].act
            @reset gt[i].tk_cm .= gt[i].tk_c0 .* gt[i].fat .* gt[i].act
        end
    end
    return gt
end

```

Even better would be @Unroll\_then\_reset for cases where `@reset` is being called on every line. I’ve yet to explore writing macros, but this discussion gives the impression it would not be trivial:

> [@A macro to unroll by hand but not by hand?](https://discourse.julialang.org/t/a-macro-to-unroll-by-hand-but-not-by-hand/74633):
>
> Hey, I have a computation that we already discussed [there](https://discourse.julialang.org/t/is-this-the-maximum-perf-i-can-obtain/74022) and which still takes up more than half of my total runtime (so days…). I did found a very clunky way to cut in half it’s runtime by manually unrolling a loop, which allowed to remove some allocations. Unfortunately, this only works for a given value of M, as i have to write the code by hand (writting the loop will prevent @tturbo to work since its order do matter). Maybe there is a way to do it programatically for all M ? Here is the …

---

_[View the full topic](https://discourse.julialang.org/t/svectors-reset-from-accessors-strange-benchmarks/119201)._
