@@ -55,16 +55,20 @@ function gc_alloc_count(diff::GC_Diff)
55
55
diff. malloc + diff. realloc + diff. poolalloc + diff. bigalloc
56
56
end
57
57
58
- # cumulative total time spent on compilation, in nanoseconds
59
- function cumulative_compile_time_ns_before ()
60
- comp = ccall (:jl_cumulative_compile_time_ns_before , UInt64, ())
61
- recomp = ccall (:jl_cumulative_recompile_time_ns_before , UInt64, ())
58
+ # cumulative total time spent on compilation and recompilation , in nanoseconds
59
+ function cumulative_compile_time_ns ()
60
+ comp = ccall (:jl_cumulative_compile_time_ns , UInt64, ())
61
+ recomp = ccall (:jl_cumulative_recompile_time_ns , UInt64, ())
62
62
return comp, recomp
63
63
end
64
- function cumulative_compile_time_ns_after ()
65
- comp = ccall (:jl_cumulative_compile_time_ns_after , UInt64, ())
66
- recomp = ccall (:jl_cumulative_recompile_time_ns_before , UInt64, ())
67
- return comp, recomp
64
+
65
+ function cumulative_compile_timing (b:: Bool )
66
+ if b
67
+ ccall (:jl_cumulative_compile_timing_enable , Cvoid, ())
68
+ else
69
+ ccall (:jl_cumulative_compile_timing_disable , Cvoid, ())
70
+ end
71
+ return
68
72
end
69
73
70
74
# total time spend in garbage collection, in nanoseconds
@@ -127,7 +131,7 @@ function time_print(elapsedtime, bytes=0, gctime=0, allocs=0, compile_time=0, re
127
131
str = sprint () do io
128
132
_lpad && print (io, length (timestr) < 10 ? (" " ^ (10 - length (timestr))) : " " )
129
133
print (io, timestr, " seconds" )
130
- parens = bytes != 0 || allocs != 0 || gctime > 0 || compile_time > 0
134
+ parens = bytes != 0 || allocs != 0 || gctime > 0 || compile_time > 0 || recompile_time > 0
131
135
parens && print (io, " (" )
132
136
if bytes != 0 || allocs != 0
133
137
allocs, ma = prettyprint_getunits (allocs, length (_cnt_units), Int64 (1000 ))
@@ -151,7 +155,10 @@ function time_print(elapsedtime, bytes=0, gctime=0, allocs=0, compile_time=0, re
151
155
print (io, Ryu. writefixed (Float64 (100 * compile_time/ elapsedtime), 2 ), " % compilation time" )
152
156
end
153
157
if recompile_time > 0
154
- print (io, " of which " , Ryu. writefixed (Float64 (100 * recompile_time/ compile_time), 0 ), " % was recompilation" )
158
+ if bytes != 0 || allocs != 0 || gctime > 0 || compile_time > 0
159
+ print (io, " , " )
160
+ end
161
+ print (io, Ryu. writefixed (Float64 (100 * recompile_time/ elapsedtime), 2 ), " % recompilation time" )
155
162
end
156
163
parens && print (io, " )" )
157
164
end
@@ -251,10 +258,12 @@ macro time(msg, ex)
251
258
Experimental. @force_compile
252
259
local stats = gc_num ()
253
260
local elapsedtime = time_ns ()
254
- local compile_elapsedtimes = cumulative_compile_time_ns_before ()
261
+ cumulative_compile_timing (true )
262
+ local compile_elapsedtimes = cumulative_compile_time_ns ()
255
263
local val = @__tryfinally ($ (esc (ex)),
256
264
(elapsedtime = time_ns () - elapsedtime;
257
- compile_elapsedtimes = cumulative_compile_time_ns_after () .- compile_elapsedtimes)
265
+ cumulative_compile_timing (false );
266
+ compile_elapsedtimes = cumulative_compile_time_ns () .- compile_elapsedtimes)
258
267
)
259
268
local diff = GC_Diff (gc_num (), stats)
260
269
local _msg = $ (esc (msg))
@@ -333,10 +342,10 @@ macro timev(msg, ex)
333
342
Experimental. @force_compile
334
343
local stats = gc_num ()
335
344
local elapsedtime = time_ns ()
336
- local compile_elapsedtimes = cumulative_compile_time_ns_before ()
345
+ local compile_elapsedtimes = cumulative_compile_time_ns ()
337
346
local val = @__tryfinally ($ (esc (ex)),
338
347
(elapsedtime = time_ns () - elapsedtime;
339
- compile_elapsedtimes = cumulative_compile_time_ns_after () .- compile_elapsedtimes)
348
+ compile_elapsedtimes = cumulative_compile_time_ns () .- compile_elapsedtimes)
340
349
)
341
350
local diff = GC_Diff (gc_num (), stats)
342
351
local _msg = $ (esc (msg))
0 commit comments