ProfileView.jl icon indicating copy to clipboard operation
ProfileView.jl copied to clipboard

don't display overhead when called from include()

Open mattuntergassmair opened this issue 5 years ago • 1 comments

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)

From REPL: Screenshot from 2020-01-12 12-33-06

Via include("profile_my_stuff.jl"): Screenshot from 2020-01-12 12-32-41

My attempt using the pruned keyword:

ProfileView.Profile.clear()
ProfileView.@profile profile_test(10)
ProfileView.view(;pruned=[("include", "Base.jl"), ("run_backend", "Revise.jl")])

mattuntergassmair avatar Jan 12 '20 20:01 mattuntergassmair

Maybe related to #121

mattuntergassmair avatar Jan 12 '20 20:01 mattuntergassmair