Skip to content

Commit bc44e3a

Browse files
committed
Add support for specifying the output directory
1 parent e8158d8 commit bc44e3a

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/StatProfilerHTML.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ import .Reports: Report
1313
import .HTML: output
1414

1515
function statprofilehtml(data::Vector{<:Unsigned} = UInt[], litrace::LineInfoDict = LineInfoDict();
16-
from_c=false)
16+
from_c=false, path="statprof")
1717
if length(data) == 0
1818
(data, litrace) = Profile.retrieve()
1919
end
2020

21+
fullpath = abspath(path)
22+
2123
report = Report(data, litrace, from_c)
2224
sort!(report)
23-
HTML.output(report, "statprof")
25+
HTML.output(report, fullpath)
2426

25-
@info "Wrote profiling output to file://$(pwd())/statprof/index.html ."
27+
@info "Wrote profiling output to file://$fullpath/index.html ."
2628
end
2729

2830
macro profilehtml(expr)

test/runtests.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ end
3333
end
3434
end
3535

36+
@testset "non-standard path" begin
37+
mktempdir() do dir
38+
cd(dir) do
39+
@profile fibonacci(43)
40+
41+
statprofilehtml(path="foobar")
42+
43+
@test isdir("foobar")
44+
@test !isdir("statprof")
45+
end
46+
end
47+
end
48+
3649
@testset "@profilehtml" begin
3750
mktempdir() do dir
3851
cd(dir) do

0 commit comments

Comments
 (0)