this is my first post, please be kind.
I want to test hypothesis where the allocation happens and time is spent in my functions. I imagine doing it the following way:
function fr(x::Int64,y::Int64) a = 0 @time for i=1:1000000000 a = x^x end return y^y-a end fr(8,9)
Having to introduce a loop so you see what is going on is one reason why @btime is usually preferred. However
using BenchmarkTools function fr(x::Int64,y::Int64) @btime a = x^x return y^y-a end fr(8,9)
Causes Julia much pain:
ERROR: UndefVarError: x not defined
My versioninfo() is:
Julia Version 1.0.3 Commit 099e826241 (2018-12-18 01:34 UTC) Platform Info: OS: Linux (x86_64-redhat-linux) CPU: Intel(R) Core(TM) i5-8XXU CPU @ X.XGHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-6.0.0 (ORCJIT, skylake)
Any ideas how i can get a better idea about the performance behavior of parts of my program?
As far as i understand it:
@btime is expanded as a macro and executed at parse/compile time, at which x is not known
I do not understand why my first case works at all since it’s a macro too.