Skip to content

Commit 0eaaea1

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 ce78c9a commit 0eaaea1

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
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)

src/ml.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ function schema(xs::DArray)
2525
delayedmap(x -> schema(x), xs.chunks)))
2626
end
2727

28-
function schema(xs::DArray, T)
29-
collect(treereduce(delayed(merge),
30-
delayedmap(x -> schema(x, T), xs.chunks)))
31-
end
32-
3328
schema(xs::ArrayOp) = schema(compute(xs))
3429
schema(xs::ArrayOp, T) = schema(compute(xs), T)
3530

@@ -87,6 +82,13 @@ function schema(xs::PooledArray)
8782
schema(xs, Categorical)
8883
end
8984

85+
for T in (:Continuous, :Categorical)
86+
@eval function schema(xs::DArray, ::Type{$T})
87+
collect(treereduce(delayed(merge),
88+
delayedmap(x -> schema(x, $T), xs.chunks)))
89+
end
90+
end
91+
9092
Base.keys(c::Categorical) = keys(c.series.stats[1])
9193
width(c::Categorical) = length(keys(c))
9294
merge(c1::Categorical, c2::Categorical) = Categorical(merge(c1.series, c2.series))

0 commit comments

Comments
 (0)