# Bug in BenchmarkTools?

**URL:** <https://discourse.julialang.org/t/bug-in-benchmarktools/94273>\
**Category:** General Usage\
**Created:** [February 8, 2023, 12:54pm UTC](https://discourse.julialang.org/t/bug-in-benchmarktools/94273 "2023-02-08T12:54:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [February 8, 2023, 12:54pm UTC](https://discourse.julialang.org/t/bug-in-benchmarktools/94273/1 "2023-02-08T12:54:09Z")

</div>

Is this a bug, or am I missing something?

```julia
julia> using StaticArrays

julia> m = rand(SMatrix{3,3,Float64});

julia> f(m::SMatrix{N,N,T}) where {N,T} = SMatrix{N,N,T,N*N}(m[c] for c in CartesianIndices(m))
f (generic function with 1 method)

julia> f(m) # fine
3×3 SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 0.256642 0.842059 0.421776
 0.408755 0.266084 0.887893
 0.0570036 0.402704 0.260989

julia> @btime f($m)
ERROR: MethodError: objects of type SVector{2, Float64} are not callable
Use square brackets [] for indexing an Array.

```

---

<div class="post-metadata">

**Author:** ![barucden](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barucden/32/26154_2.png) [@barucden](https://discourse.julialang.org/u/barucden)\
**Post date:** [February 8, 2023, 1:08pm UTC](https://discourse.julialang.org/t/bug-in-benchmarktools/94273/2 "2023-02-08T13:08:27Z")

</div>

Works for me!

```julia
julia> using BenchmarkTools

julia> using StaticArrays

julia> m = rand(SMatrix{3,3,Float64});

julia> f(m::SMatrix{N,N,T}) where {N,T} = SMatrix{N,N,T,N*N}(m[c] for c in CartesianIndices(m))
f (generic function with 1 method)

julia> f(m) # fine
3×3 SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 0.31864 0.478805 0.430077
 0.31005 0.541521 0.241841
 0.284379 0.569089 0.00424923

julia> @btime f($m)
  3.821 ns (0 allocations: 0 bytes)
3×3 SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 0.31864 0.478805 0.430077
 0.31005 0.541521 0.241841
 0.284379 0.569089 0.00424923

julia> versioninfo()
Julia Version 1.8.5
Commit 17cfb8e65ea (2023-01-08 06:45 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 4 × Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, haswell)
  Threads: 1 on 4 virtual cores

```

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [February 8, 2023, 1:17pm UTC](https://discourse.julialang.org/t/bug-in-benchmarktools/94273/3 "2023-02-08T13:17:47Z")

</div>

Yeah, tested here again in fresh sessions and it works now. It was probably a world-age problem.
