Skip to content
Open
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
8 changes: 5 additions & 3 deletions 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 = "1.10.1"
author = ["Tim Holy <[email protected]>"]

[deps]
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
Expand All @@ -12,6 +12,7 @@ FlameGraphs = "08572546-2f56-4bcf-ba4e-bab62c3a3f89"
Graphics = "a2bd30eb-e257-5431-a919-1863eab51364"
Gtk4 = "9db2cae5-386f-4011-9d63-a5602296539b"
GtkObservables = "8710efd8-4ad6-11eb-33ea-2d5ceb25a41c"
IOCapture = "b5f81e59-6552-4d32-b1f0-c071b021bf89"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
MethodAnalysis = "85b6ec6f-f7df-4429-9514-a64bcd9ee824"
Expand All @@ -29,20 +30,21 @@ ProfileViewCthulhuExt = "Cthulhu"
[compat]
Cairo = "0.6, 0.8, 1"
Colors = "0.12, 0.13"
Dates = "1"
Cthulhu = "2"
Dates = "1"
FileIO = "1.6"
FlameGraphs = "0.2.10, 1"
Graphics = "0.4, 1"
Gtk4 = "0.7.6"
GtkObservables = "2"
IOCapture = "0.2.5"
InteractiveUtils = "1"
IntervalSets = "0.2, 0.3, 0.4, 0.5, 0.6, 0.7"
MethodAnalysis = "0.4"
PrecompileTools = "1"
Preferences = "1.2"
REPL = "1"
Profile = "1"
REPL = "1"
Test = "1"
UUIDs = "1"
julia = "1.10"
Expand Down
37 changes: 36 additions & 1 deletion src/ProfileView.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ import GtkObservables: Canvas
import Cairo
using Graphics
using Preferences
using IOCapture

using FlameGraphs: Node, NodeData
const CONTROL = Gtk4.ModifierType_CONTROL_MASK

export @profview, warntype_clicked, descend_clicked, ascend_clicked
export @profview, warntype_clicked, descend_clicked, ascend_clicked, view_tree
@deprecate warntype_last warntype_clicked

const clicked = Ref{Any}(nothing) # for getting access to the clicked bar
Expand Down Expand Up @@ -654,6 +655,40 @@ end
discardfirstcol(A) = A[:,2:end]
discardfirstcol(A::IndirectArray) = IndirectArray(A.index[:,2:end], A.values)

include("treeview.jl")
using .TreeView: show_profile_tree

"""
view_tree([data]; kwargs...)

View profiling results in a collapsible tree view format, similar to how
`Profile.print` displays the data. This provides a hierarchical view that
can be expanded and collapsed interactively.

# Arguments
- `data`: Optional profile data from `Profile.fetch()`. If not provided, will use the current profile data.

# Keyword Arguments
- All keyword arguments accepted by `Profile.print` including:
- `lidict`: Line info dictionary from `Profile.retrieve()`
- `C`: If true, includes C functions in the output
- `recur`: How to handle recursion (:off, :flat, or :nested)
- `noisefloor`: Hide functions with counts below this threshold
- `windowname`: Name for the tree view window. Default is "Profile Tree View".

# Examples
```julia
# View current profile data
view_tree()

# View with specific options
view_tree(C=true, noisefloor=2)
```
"""
function view_tree(data::Vector{UInt64}=Profile.fetch(); lidict=nothing, kwargs...)
return show_profile_tree(data; lidict=lidict, kwargs...)
end

function __init__()
Base.Experimental.register_error_hint(MethodError) do io, exc, argtypes, kwargs
if (exc.f === descend_clicked || exc.f === ascend_clicked) && isempty(argtypes)
Expand Down
Loading
Loading