Skip to content

Commit b78440f

Browse files
committed
Wrap result of tracktime in a struct to have a custom show method
and avoid unconditional printing of timing results
1 parent ae4831d commit b78440f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/diagnostics.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ function stop_tracking_time()
8484
compute_context[] = nothing
8585
end
8686

87+
struct TrackTime
88+
obj
89+
end
90+
91+
Base.show(io::IO, ::MIME"text/plain", t::TrackTime) = show_timings(t.obj, maxdepth=5)
92+
8793
"""
8894
`tracktime(f)`
8995
@@ -96,8 +102,7 @@ function tracktime(f; profile=false, maxdepth=5)
96102
ctx = compute_context[]
97103
stop_tracking_time()
98104
t = fetch_timings!(ctx, profile=profile)
99-
show_timings(t, maxdepth=maxdepth)
100-
t, res
105+
TrackTime(t), res
101106
end
102107

103108
function fetch_timings!(ctx=get_context(); profile=true)

0 commit comments

Comments
 (0)