0
votes

I am trying to get an idea of all of the functions in my code that a specific script calls. Is there a way in Julia that I can run a file, and see all of the functions that are called specifically within my own code?

I know profiling may be an option, but I am unsure if that will actually give me functions names and if I could specify to only look through internal functions (I want to avoid base functions in the output).

1
I'm not proficient with Julia yet, but isn't this effectively Profiling?r2evans
Strange ideas using --trace-compile come to mind. It would only list functions that haven't yet been compiled though.carstenbauer

1 Answers

4
votes

This is certainly not what you want but I'll archive the idea here anyways.

If you run julia --trace-compile=calls.txt myscript.jl with myscript.jl being

# myscript.jl
myfunc(a) = a^2

anotherfunc(b) = sin(b)+3

myfunc(4)

anotherfunc(1.23)

Julia will create a file calls.txt with the following content

precompile(Tuple{typeof(Main.myfunc), Int64})
precompile(Tuple{typeof(Main.anotherfunc), Float64})
precompile(Tuple{typeof(Base._atexit)})
precompile(Tuple{typeof(Base.uvfinalize), Base.TTY})

As you can see, it tells you that Main.myfunc and Main.anotherfunc have been called with Int64 and Float64 arguments respectively. Probably not quite what you want but perhaps an interesting idea to build upon.