@@ -1254,22 +1254,9 @@ function _include_from_serialized(pkg::PkgId, path::String, ocachepath::Union{No
1254
1254
if parentmodule (M) === M && PkgId (M) == pkg
1255
1255
register && register_root_module (M)
1256
1256
if timing_imports
1257
- elapsed = round (( time_ns () - t_before) / 1e6 , digits = 1 )
1257
+ elapsed_time = time_ns () - t_before
1258
1258
comp_time, recomp_time = cumulative_compile_time_ns () .- t_comp_before
1259
- print (lpad (elapsed, 9 ), " ms " )
1260
- ext_parent = extension_parent_name (M)
1261
- if ext_parent != = nothing
1262
- print (ext_parent:: String , " → " )
1263
- end
1264
- print (pkg. name)
1265
- if comp_time > 0
1266
- printstyled (" " , Ryu. writefixed (Float64 (100 * comp_time / (elapsed * 1e6 )), 2 ), " % compilation time" , color = Base. info_color ())
1267
- end
1268
- if recomp_time > 0
1269
- perc = Float64 (100 * recomp_time / comp_time)
1270
- printstyled (" (" , perc < 1 ? " <1" : Ryu. writefixed (perc, 0 ), " % recompilation)" , color = Base. warn_color ())
1271
- end
1272
- println ()
1259
+ print_time_imports_report (M, elapsed_time, comp_time, recomp_time)
1273
1260
end
1274
1261
return M
1275
1262
end
@@ -1281,6 +1268,52 @@ function _include_from_serialized(pkg::PkgId, path::String, ocachepath::Union{No
1281
1268
end
1282
1269
end
1283
1270
1271
+ # printing functions for @time_imports
1272
+ # note that the time inputs are UInt64 on all platforms. Give default values here so that we don't have
1273
+ # confusing UInt64 types in generate_precompile.jl
1274
+ function print_time_imports_report (
1275
+ mod:: Module ,
1276
+ elapsed_time:: UInt64 = UInt64 (1 ),
1277
+ comp_time:: UInt64 = UInt64 (1 ),
1278
+ recomp_time:: UInt64 = UInt64 (1 )
1279
+ )
1280
+ print (lpad (round (elapsed_time / 1e6 , digits= 1 ), 9 ), " ms " )
1281
+ ext_parent = extension_parent_name (mod)
1282
+ if ext_parent != = nothing
1283
+ print (ext_parent:: String , " → " )
1284
+ end
1285
+ print (string (mod))
1286
+ if comp_time > 0
1287
+ perc = Ryu. writefixed (Float64 (100 * comp_time / (elapsed_time)), 2 )
1288
+ printstyled (" $perc % compilation time" , color = Base. info_color ())
1289
+ end
1290
+ if recomp_time > 0
1291
+ perc = Float64 (100 * recomp_time / comp_time)
1292
+ perc_show = perc < 1 ? " <1" : Ryu. writefixed (perc, 0 )
1293
+ printstyled (" ($perc_show % recompilation)" , color = Base. warn_color ())
1294
+ end
1295
+ println ()
1296
+ end
1297
+ function print_time_imports_report_init (
1298
+ mod:: Module , i:: Int = 1 ,
1299
+ elapsed_time:: UInt64 = UInt64 (1 ),
1300
+ comp_time:: UInt64 = UInt64 (1 ),
1301
+ recomp_time:: UInt64 = UInt64 (1 )
1302
+ )
1303
+ connector = i > 1 ? " ├" : " ┌"
1304
+ printstyled (" $connector " , color = :light_black )
1305
+ print (" $(round (elapsed_time / 1e6 , digits= 1 )) ms $mod .__init__() " )
1306
+ if comp_time > 0
1307
+ perc = Ryu. writefixed (Float64 (100 * (comp_time) / elapsed_time), 2 )
1308
+ printstyled (" $perc % compilation time" , color = Base. info_color ())
1309
+ end
1310
+ if recomp_time > 0
1311
+ perc = Float64 (100 * recomp_time / comp_time)
1312
+ printstyled (" ($(perc < 1 ? " <1" : Ryu. writefixed (perc, 0 )) % recompilation)" , color = Base. warn_color ())
1313
+ end
1314
+ println ()
1315
+ end
1316
+
1284
1317
# if M is an extension, return the string name of the parent. Otherwise return nothing
1285
1318
function extension_parent_name (M:: Module )
1286
1319
rootmodule = moduleroot (M)
@@ -1338,31 +1371,18 @@ function run_module_init(mod::Module, i::Int=1)
1338
1371
# `i` informs ordering for the `@time_imports` report formatting
1339
1372
if TIMING_IMPORTS[] == 0
1340
1373
ccall (:jl_init_restored_module , Cvoid, (Any,), mod)
1341
- else
1342
- if isdefined (mod, :__init__ )
1343
- connector = i > 1 ? " ├" : " ┌"
1344
- printstyled (" $connector " , color = :light_black )
1345
-
1346
- elapsedtime = time_ns ()
1347
- cumulative_compile_timing (true )
1348
- compile_elapsedtimes = cumulative_compile_time_ns ()
1374
+ elseif isdefined (mod, :__init__ )
1375
+ elapsed_time = time_ns ()
1376
+ cumulative_compile_timing (true )
1377
+ compile_elapsedtimes = cumulative_compile_time_ns ()
1349
1378
1350
- ccall (:jl_init_restored_module , Cvoid, (Any,), mod)
1379
+ ccall (:jl_init_restored_module , Cvoid, (Any,), mod)
1351
1380
1352
- elapsedtime = ( time_ns () - elapsedtime) / 1e6
1353
- cumulative_compile_timing (false );
1354
- comp_time, recomp_time = ( cumulative_compile_time_ns () .- compile_elapsedtimes) ./ 1e6
1381
+ elapsed_time = time_ns () - elapsed_time
1382
+ cumulative_compile_timing (false );
1383
+ comp_time, recomp_time = cumulative_compile_time_ns () .- compile_elapsedtimes
1355
1384
1356
- print (" $(round (elapsedtime, digits= 1 )) ms $mod .__init__() " )
1357
- if comp_time > 0
1358
- printstyled (Ryu. writefixed (Float64 (100 * comp_time / elapsedtime), 2 ), " % compilation time" , color = Base. info_color ())
1359
- end
1360
- if recomp_time > 0
1361
- perc = Float64 (100 * recomp_time / comp_time)
1362
- printstyled (" ($(perc < 1 ? " <1" : Ryu. writefixed (perc, 0 )) % recompilation)" , color = Base. warn_color ())
1363
- end
1364
- println ()
1365
- end
1385
+ print_time_imports_report_init (mod, i, elapsed_time, comp_time, recomp_time)
1366
1386
end
1367
1387
end
1368
1388
0 commit comments