Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PProf"
uuid = "e4faabce-9ead-11e9-39d9-4379958e3056"
authors = ["Valentin Churavy <[email protected]>", "Nathan Daly <[email protected]>"]
version = "3.2.0"
version = "3.2.1"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand All @@ -10,6 +10,7 @@ EnumX = "4e289a0a-7415-4d19-859d-a7e5c4648b56"
FlameGraphs = "08572546-2f56-4bcf-ba4e-bab62c3a3f89"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
ProtoBuf = "3349acd9-ac6a-5e09-bcdb-63829b23a429"
Expand All @@ -21,6 +22,7 @@ CodecZlib = "0.7"
EnumX = "1"
FlameGraphs = "0.2, 1"
OrderedCollections = "1.1"
PrecompileTools = "1.2"
ProgressMeter = "1.7"
ProtoBuf = "1"
julia = "1.6"
Expand Down
31 changes: 27 additions & 4 deletions src/PProf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ using CodecZlib
import pprof_jll

using Profile: clear
using PrecompileTools: @setup_workload, @compile_workload # this is a small dependency

"""
PProf.clear()
Expand Down Expand Up @@ -417,9 +418,31 @@ end

# Precompile as much as possible, so that profiling doesn't end up measuring our own
# compilation.
function __init__()
precompile(pprof, ()) || error("precompilation of package functions is not supposed to fail")
precompile(kill, ()) || error("precompilation of package functions is not supposed to fail")
precompile(refresh, ()) || error("precompilation of package functions is not supposed to fail")
@static if Base.VERSION >= v"1.8.0-"
@setup_workload begin
using Profile
f1() = sum(collect(1:1e7))
f1()
f2() = [[] for _ in 1:5]
f2()
@compile_workload begin
redirect_stderr(devnull) do
Profile.@profile f1()
Profile.Allocs.@profile f2()
PProf.pprof(web=false)
PProf.Allocs.pprof(web=false)
PProf.refresh()
PProf.kill()
end
end
end
else
function __init__()
@assert precompile(pprof, ()) "precompilation of package functions is not supposed to fail: pprof()"
# Allocs.pprof only defined in v1.9+
@assert precompile(refresh, ()) "precompilation of package functions is not supposed to fail: refresh()"
@assert precompile(kill, ()) "precompilation of package functions is not supposed to fail: kill()"
end
end

end # module
Loading