-
Notifications
You must be signed in to change notification settings - Fork 38
Description
I'm using ProfileView to find out which parts of my code need to be optimized. Since the function I am looking at needs quite some preparation (defining variables, building structs, etc.) I decided to put everything inside a profile_my_stuff.jl
. All works fine but the graph generated by view()
shows quite some overhead left and right of my actual code. (caused by Revise.jl and Base.jl), see screenshot. Is there any way to get rid of these parts? I tried using the pruned
keyword to get rid of these parts but it didn't work. I realize I could always just define my variables through the script and then run @profview from the REPL, but being able to have everything in a file would be neat.
Code to reproduce (run directly from REPL or via include("profile_my_stuff.jl")
:
using ProfileView
function profile_test(n)
for i = 1:n
A = randn(100,100,20)
m = maximum(A)
Am = mapslices(sum, A; dims=2)
B = A[:,:,5]
Bsort = mapslices(sort, B; dims=1)
b = rand(100)
C = B.*b
end
end
@profview profile_test(1) # run once to trigger compilation (ignore this one)
@profview profile_test(10)
Via include("profile_my_stuff.jl")
:
My attempt using the pruned
keyword:
ProfileView.Profile.clear()
ProfileView.@profile profile_test(10)
ProfileView.view(;pruned=[("include", "Base.jl"), ("run_backend", "Revise.jl")])