Skip to content

Commit

Permalink
Merge branch 'main' into vc/compress
Browse files Browse the repository at this point in the history
  • Loading branch information
NHDaly authored Oct 6, 2023
2 parents e61daf8 + 45399a8 commit a59d315
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 25 deletions.
33 changes: 24 additions & 9 deletions test/PProf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using CodecZlib

const out = tempname() * ".pb.gz"

function foo(n, a, out=[])
@noinline function foo(n, a, out=[])
# make this expensive to ensure it's sampled
for i in 1:n
push!(out, i*a)
Expand All @@ -27,10 +27,13 @@ end
@testset "export basic profile" begin
Profile.clear()

@profile for i in 1:10000
# Profile compilation
@eval foo(x,y) = x * y + x / y
@eval foo($i,3)
while Profile.len_data() == 0
@profile for i in 1:10000
# Profile compilation
foo_sym = Symbol("foo$i)")
@eval $foo_sym(x,y) = x * y + x / y
@eval $foo_sym($i,3)
end
end

# Cache profile output to test that it isn't changed
Expand Down Expand Up @@ -66,7 +69,9 @@ end
Profile.clear()

let arr = []
@profile foo(1000000, 5, arr)
while Profile.len_data() == 0
@profile foo(1000000, 5, arr)
end
sleep(2)
end
for i in 1:2
Expand All @@ -93,10 +98,20 @@ end

@testset "full_signatures" begin
Profile.clear()
@profile foo(1000000, 5, [])
while Profile.len_data() == 0
# Use @eval and @time to make sure we don't interpret foo, and thus break the full-signature test
@profile @eval @time foo(1000000, 5, [])
end
@test "foo" in load_prof_proto(pprof(out=tempname(), web=false, full_signatures = false)).string_table
@test any(occursin.(Regex("^foo\\(::$Int, ::$Int, ::(Vector|Array)"),
load_prof_proto(pprof(out=tempname(), web=false, full_signatures = true)).string_table))

string_data = load_prof_proto(pprof(out=tempname(), web=false, full_signatures = true)).string_table
found_full_sig = any(occursin.(Regex("^foo\\(::$Int, ::$Int, ::(Vector|Array)"), string_data))
@test found_full_sig
# Log what we got instead
if !found_full_sig
println("expected foo(...), but got:")
@show string_data
end
end

@testset "drop_frames/keep_frames" begin
Expand Down
11 changes: 7 additions & 4 deletions test/flamegraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ end
@testset "export basic profile" begin
Profile.clear()

let x = 1
@profile for _ in 1:1000000; x += 1; end
sleep(2)
while Profile.len_data() == 0
let x = 5
@profile @time for _ in 1:10000; x += 1; end
end
end

# Collect the profile via FlameGraphs
Expand Down Expand Up @@ -72,7 +73,9 @@ end
Profile.clear()

let arr = []
@profile foo(1000000, 5, arr)
while Profile.len_data() == 0
@profile foo(1000000, 5, arr)
end
sleep(2)
end

Expand Down
26 changes: 14 additions & 12 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ using Profile

Profile.init()

@testset "PProf.jl" begin
include("PProf.jl")
end

@testset "flamegraphs.jl" begin
include("flamegraphs.jl")
end
@testset "PProf" begin
@testset "PProf.jl" begin
include("PProf.jl")
end

@static if isdefined(Profile, :Allocs) # PR https://github.com/JuliaLang/julia/pull/42768
@testset "Allocs.jl" begin
include("Allocs.jl")
@testset "flamegraphs.jl" begin
include("flamegraphs.jl")
end

@testset "Regression tests" begin
include("golden/regression_test.jl")
@static if isdefined(Profile, :Allocs) # PR https://github.com/JuliaLang/julia/pull/42768
@testset "Allocs.jl" begin
include("Allocs.jl")
end

@testset "Regression tests" begin
include("golden/regression_test.jl")
end
end
end

0 comments on commit a59d315

Please sign in to comment.