Skip to content

Commit

Permalink
Merge pull request #119 from timholy/teh/profview
Browse files Browse the repository at this point in the history
Add atsign-profview
  • Loading branch information
timholy authored Oct 31, 2019
2 parents 945de22 + 4413d05 commit ceeef54
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
13 changes: 9 additions & 4 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 = "0.4.1"
version = "0.5"

[deps]
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
Expand All @@ -16,11 +16,16 @@ Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
Cairo = "≥ 0.5.6"
Graphics = "≥ 0.2.0"
GtkReactive = "≥ 0.5.1"
Cairo = "0.5, 0.6"
Colors = "0.9"
FileIO = "1"
Graphics = "0.2, 0.3, 0.4"
Gtk = "0.16, 0.17, 0.18"
GtkReactive = "0.5.1, 0.6"
IntervalSets = "0.2, 0.3"
julia = "0.7, 1"


[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

Expand Down
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,13 @@ function profile_test(n)
end
end

profile_test(1) # run once to trigger compilation
using Profile
Profile.clear() # in case we have any previous profiling data
@profile profile_test(10)
using ProfileView
@profview profile_test(1) # run once to trigger compilation (ignore this one)
@profview profile_test(10)
```
Now that we have profiling data, visualizing it is a simple matter:
```
julia> using ProfileView

julia> ProfileView.view()
```
`@profview f(args...)` is just shorthand for `Profile.clear(); @profile f(args...); ProfileView.view()`.

If you're following along, you should see something like this:

![ProfileView](readme_images/pv1.jpg)
Expand Down
15 changes: 15 additions & 0 deletions src/ProfileView.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ using Colors

import Base: isequal, show

export @profview

"""
@profview f(args...)
Clear the Profile buffer, profile `f(args...)`, and view the result graphically.
"""
macro profview(ex)
return quote
Profile.clear()
@profile $(esc(ex))
view()
end
end

include("tree.jl")
include("pvtree.jl")

Expand Down
5 changes: 4 additions & 1 deletion test/test.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Profile
using ProfileView

function profile_test(n)
Expand Down Expand Up @@ -35,6 +34,10 @@ function profile_unstable_test(m, n)
end

profile_test(1)
@profview profile_test(10)

using Profile

Profile.clear()
@profile profile_test(10)
ProfileView.view()
Expand Down

2 comments on commit ceeef54

@timholy
Copy link
Owner Author

Choose a reason for hiding this comment

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

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/4935

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.0 -m "<description of version>" ceeef54ac8ebb2efa28b5bf12036c5bb86fbe454
git push origin v0.5.0

Please sign in to comment.