# Performance of filling an array

**URL:** <https://discourse.julialang.org/t/performance-of-filling-an-array/22788>\
**Category:** General Usage\
**Tags:** performance\
**Created:** [April 5, 2019, 9:38am UTC](https://discourse.julialang.org/t/performance-of-filling-an-array/22788 "2019-04-05T09:38:55Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [April 5, 2019, 2:00pm UTC](https://discourse.julialang.org/t/performance-of-filling-an-array/22788/3 "2019-04-05T14:00:59Z")

</div>

Looks kind of similar to

> [@Possible inefficiency in randn!](https://discourse.julialang.org/t/possible-inefficiency-in-randn/22732/5):
>
> I was confused in the previous post, sorry. That has nothing to do with simd: using Random broadcast\_randn(x) = (x .= randn.()) inplace\_randn(x) = randn!(x) function myrandn!(x) @inbounds @simd for i in eachindex(x) x[i] = randn() end x end function myrandn\_nosimd!(x) @inbounds for i in eachindex(x) x[i] = randn() end x end x = zeros(10\_000) @btime broadcast\_randn($x); @btime inplace\_randn($x); @btime myrandn!($x); @btime myrandn\_nosimd!($x); is only…

---

_[View the full topic](https://discourse.julialang.org/t/performance-of-filling-an-array/22788)._
