Skip to content

Commit

Permalink
Fix profiler for Dict change; add basic "does it work at all?" tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Oct 8, 2014
1 parent 8acd981 commit fbd4463
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/profile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ end

function getdict(data::Vector{Uint})
uip = unique(data)
Dict(uip, [lookup(ip) for ip in uip])
Dict{Uint, LineInfo}([ip=>lookup(ip) for ip in uip])
end

function callers(funcname::ByteString, bt::Vector{Uint}, lidict; filename = nothing, linerange = nothing)
Expand Down
14 changes: 14 additions & 0 deletions test/profile.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@profile sleep(0.1)
let iobuf = IOBuffer()
Profile.print(iobuf)
str = takebuf_string(iobuf)
@test !isempty(str)
Profile.print(iobuf, format=:flat)
str = takebuf_string(iobuf)
@test !isempty(str)
Profile.print(iobuf, format=:tree, C=true)
str = takebuf_string(iobuf)
@test !isempty(str)
Profile.clear()
@test isempty(Profile.fetch())
end
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ testnames = [
"floatapprox", "readdlm", "reflection", "regex", "float16", "combinatorics",
"sysinfo", "rounding", "ranges", "mod2pi", "euler", "show",
"lineedit", "replcompletions", "repl", "test", "goto",
"llvmcall", "grisu", "nullable", "meta", "staged"
"llvmcall", "grisu", "nullable", "meta", "staged", "profile"
]

if isdir(joinpath(dirname(@__FILE__), "..", "examples"))
Expand Down

2 comments on commit fbd4463

@jakebolewski
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change related to this Travis failure?

WARNING: There were no samples collected. Run your program longer (perhaps by
running it multiple times), or adjust the delay between samples with
Profile.init().
exception on 2: ERROR: test failed: !(isempty(str))
 in expression: !(isempty(str))
 in error at error.jl:21
 in default_handler at test.jl:25
 in do_test at test.jl:50
 in runtests at /private/tmp/julia/share/julia/test/testdefs.jl:5
 in anonymous at multi.jl:827
 in run_work_thunk at multi.jl:593
 in anonymous at task.jl:827
while loading profile.jl, in expression starting on line 5
ERROR: test failed: !(isempty(str))
 in expression: !(isempty(str))
 in anonymous at task.jl:1446
while loading profile.jl, in expression starting on line 5
while loading /private/tmp/julia/share/julia/test/runtests.jl, in expression starting on line 40

@timholy
Copy link
Member Author

@timholy timholy commented on fbd4463 Oct 8, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must be. How the heck can that happen? Sampling interval is 1ms.

I'll try making it a busy-wait for 1s and see what happens.

Please sign in to comment.