Skip to content

Commit 4413d05

Browse files
committed
Add atsign-profview
Closes #106
1 parent 7786a6d commit 4413d05

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ProfileView"
22
uuid = "c46f51b8-102a-5cf2-8d2c-8597cb0e0da7"
33
author = ["Tim Holy <[email protected]>"]
4-
version = "0.4.1"
4+
version = "0.5"
55

66
[deps]
77
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"

README.md

+5-9
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,13 @@ function profile_test(n)
4242
end
4343
end
4444

45-
profile_test(1) # run once to trigger compilation
46-
using Profile
47-
Profile.clear() # in case we have any previous profiling data
48-
@profile profile_test(10)
45+
using ProfileView
46+
@profview profile_test(1) # run once to trigger compilation (ignore this one)
47+
@profview profile_test(10)
4948
```
50-
Now that we have profiling data, visualizing it is a simple matter:
51-
```
52-
julia> using ProfileView
5349

54-
julia> ProfileView.view()
55-
```
50+
`@profview f(args...)` is just shorthand for `Profile.clear(); @profile f(args...); ProfileView.view()`.
51+
5652
If you're following along, you should see something like this:
5753

5854
![ProfileView](readme_images/pv1.jpg)

src/ProfileView.jl

+15
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ using Colors
55

66
import Base: isequal, show
77

8+
export @profview
9+
10+
"""
11+
@profview f(args...)
12+
13+
Clear the Profile buffer, profile `f(args...)`, and view the result graphically.
14+
"""
15+
macro profview(ex)
16+
return quote
17+
Profile.clear()
18+
@profile $(esc(ex))
19+
view()
20+
end
21+
end
22+
823
include("tree.jl")
924
include("pvtree.jl")
1025

test/test.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Profile
21
using ProfileView
32

43
function profile_test(n)
@@ -35,6 +34,10 @@ function profile_unstable_test(m, n)
3534
end
3635

3736
profile_test(1)
37+
@profview profile_test(10)
38+
39+
using Profile
40+
3841
Profile.clear()
3942
@profile profile_test(10)
4043
ProfileView.view()

0 commit comments

Comments
 (0)