Skip to content

Commit ceeef54

Browse files
authored
Merge pull request #119 from timholy/teh/profview
Add atsign-profview
2 parents 945de22 + 4413d05 commit ceeef54

File tree

4 files changed

+33
-14
lines changed

4 files changed

+33
-14
lines changed

Project.toml

+9-4
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"
@@ -16,11 +16,16 @@ Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
1616
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
1717

1818
[compat]
19-
Cairo = "≥ 0.5.6"
20-
Graphics = "≥ 0.2.0"
21-
GtkReactive = "≥ 0.5.1"
19+
Cairo = "0.5, 0.6"
20+
Colors = "0.9"
21+
FileIO = "1"
22+
Graphics = "0.2, 0.3, 0.4"
23+
Gtk = "0.16, 0.17, 0.18"
24+
GtkReactive = "0.5.1, 0.6"
25+
IntervalSets = "0.2, 0.3"
2226
julia = "0.7, 1"
2327

28+
2429
[extras]
2530
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2631

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)