Hi Forum,

Can someone enlighten me as to why a single Float64 export from inside a function takes as much computation time as 2,000,000 additions? See code below from Julia 1.1.

```
module test
struct teststruct
x::Array{Float64,1}
end
data=teststruct(rand(1000))
function sum_arg(data)
s = 0.0
for i in data.x
for i in data.x
s += i
end
end
end
using BenchmarkTools
timer() = @time sum_arg(data)
timer()
timer()
timer()
timer()
end
OUTPUTS:
0.008286 seconds (11.14 k allocations: 527.958 KiB)
0.000303 seconds
0.000302 seconds
0.000302 seconds
```

and compare that computation time with the computation time seen below:

```
module test
struct teststruct
x::Array{Float64,1}
end
data=teststruct(rand(1000))
function sum_arg(data)
s = 0.0
for i in data.x
for i in data.x
s += i
end
end
data.x[1]=s
end
using BenchmarkTools
timer() = @time sum_arg(data)
timer()
timer()
timer()
timer()
end
OUTPUTS:
0.012986 seconds (11.54 k allocations: 548.084 KiB)
0.000886 seconds (2 allocations: 32 bytes)
0.000884 seconds (2 allocations: 32 bytes)
0.000884 seconds (2 allocations: 32 bytes)
```

and compare the above computation time to the computation time below:

```
module test
struct teststruct
x::Array{Float64,1}
end
data=teststruct(rand(1000))
function sum_arg(data)
s = 0.0
for i in data.x
for i in data.x
s += i
end
end
return s
end
using BenchmarkTools
timer() = @time sum_arg(data)
timer()
timer()
timer()
timer()
end
OUTPUTS:
0.012986 seconds (11.54 k allocations: 548.084 KiB)
0.000886 seconds (2 allocations: 32 bytes)
0.000884 seconds (2 allocations: 32 bytes)
0.000884 seconds (2 allocations: 32 bytes)
```

I also tried another version wherein I swapped out â€śreturn sâ€ť for â€śa=1.0â€ť, and the computation time was back down to 0.0003 seconds. Therefore the function sum_arg() cannot output itâ€™s value without incurring a time penalty greater than 2,000,000 addition steps? Please enlighten me.