Skip to content

Commit

Permalink
Allow naming the window (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy authored Oct 27, 2021
1 parent a32d377 commit b71e771
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ProfileView"
uuid = "c46f51b8-102a-5cf2-8d2c-8597cb0e0da7"
author = ["Tim Holy <[email protected]>"]
version = "0.6.10"
version = "0.6.11"

[deps]
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
Expand Down
6 changes: 3 additions & 3 deletions src/ProfileView.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ end
const window_wrefs = WeakKeyDict{Gtk.GtkWindowLeaf,Nothing}()

"""
ProfileView.view([fcolor], data=Profile.fetch(); lidict=nothing, C=false, recur=:off, fontsize=14, kwargs...)
ProfileView.view([fcolor], data=Profile.fetch(); lidict=nothing, C=false, recur=:off, fontsize=14, windowname="Profile", kwargs...)
View profiling results. `data` and `lidict` must be a matched pair from `Profile.retrieve()`.
You have several options to control the output, of which the major ones are:
Expand Down Expand Up @@ -89,7 +89,7 @@ view(::Nothing; kwargs...) = view(FlameGraphs.default_colors, Node(NodeData(Stac
function view(g::Node{NodeData}; kwargs...)
view(FlameGraphs.default_colors, g; kwargs...)
end
function view(fcolor, g::Node{NodeData}; data=nothing, lidict=nothing, kwargs...)
function view(fcolor, g::Node{NodeData}; data=nothing, lidict=nothing, windowname="Profile", kwargs...)
gsig = Signal(g) # allow substitution by the open dialog
# Display in a window
c = canvas(UserUnit)
Expand All @@ -106,7 +106,7 @@ function view(fcolor, g::Node{NodeData}; data=nothing, lidict=nothing, kwargs...
# FIXME: likely have to do `allkwargs` in the two below (add in C, combine, recur)
signal_connect(open_cb, tb_open, "clicked", Nothing, (), false, (widget(c),gsig,kwargs))
signal_connect(save_as_cb, tb_save_as, "clicked", Nothing, (), false, (widget(c),data,lidict))
win = Window("Profile", 800, 600)
win = Window(windowname, 800, 600)
push!(win, bx)
GtkReactive.gc_preserve(win, c)
# Register the window with closeall
Expand Down
15 changes: 4 additions & 11 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ function profile_test(n)
end
end

function profile_simple_test(n)
for i = 1:n
A = randn(100,100,20)
m = max(A)
end
end

unstable(x) = x > 0.5 ? true : 0.0

function profile_unstable_test(m, n)
Expand All @@ -33,6 +26,8 @@ function profile_unstable_test(m, n)
s, s2
end

# These tests only ensure that code runs, and does not check the "output"

profile_test(1)
@profview profile_test(10)

Expand All @@ -43,12 +38,10 @@ Profile.clear()
ProfileView.view()
ProfileView.view(C=true)
ProfileView.view(fontsize=18)
ProfileView.view(windowname="ProfileWindow")

Profile.clear()
@profile profile_unstable_test(1, 1)
ProfileView.view(ProfileView.FlameGraphs.StackFrameCategory())

Profile.clear()
profile_unstable_test(1, 1)
@profile profile_unstable_test(10, 10^6)
ProfileView.view()

Expand Down

0 comments on commit b71e771

Please sign in to comment.