Hi all I have written a small code chunk for a generic random walk, as I am hoping to use julia for dynamic systems simulations this will be a good toy example for me to improve memory usage.

```
function rwalks(T,N,n)
#rwalks returns an array of n random walks of T steps across the set N
#T is the time step, or number of discreet steps across N
#N is the real number length of the set
#n is the number of walks performed
dt = T/N
dW = sqrt(dt)*randn(n,N)
W = zeros(n,N)
W[:,1] = dW[:,1]
for j = 2:N
W[:,j] .= W[:,j-1] .+ dW[:,j]
end
0:dt:T-dt, W
return W
end
```

With @time and one walk I get,

```
julia> @time rwalks(1, 10, 1)
0.000010 seconds (22 allocations: 2.250 KiB)
```

and for 10 walks…

```
@time rwalks(1, 10, 10)
0.000017 seconds (22 allocations: 5.594 KiB)
```

Any general suggestions I should use to improve performance? As I said I want to use this for dynamic simulations so optimizing a basic random walk would be a good first step. Apart from @time are there other macros or debugging strategies I should be using?

EDIT: Increasing the number of steps and iterations breaks it.

```
julia> @time rwalks(1, 100, 1000000)
ERROR: OutOfMemoryError()
Stacktrace:
[1] Array at .\boot.jl:408 [inlined]
[2] Array at .\boot.jl:416 [inlined]
[3] zeros at .\array.jl:525 [inlined]
[4] zeros at .\array.jl:522 [inlined]
[5] zeros at .\array.jl:520 [inlined]
[6] rwalks(::Int32, ::Int32, ::Int32) at .\REPL[7]:4
[7] top-level scope at .\timing.jl:174 [inlined]
[8] top-level scope at .\REPL[16]:0
```