@@ -169,8 +169,8 @@ function format_bytes(bytes; binary=true) # also used by InteractiveUtils
169
169
end
170
170
end
171
171
172
- function time_print (io:: IO , elapsedtime, bytes= 0 , gctime= 0 , allocs= 0 , lock_conflicts= 0 , compile_time= 0 , recompile_time= 0 , newline = false ;
173
- msg:: Union{String,Nothing} = nothing )
172
+ function time_print (io:: IO , elapsedtime, bytes= 0 , gctime= 0 , allocs= 0 , lock_conflicts= 0 , compile_time= 0 , recompile_time= 0 , wall_time_sched = 0 ,
173
+ newline = false ; msg:: Union{String,Nothing} = nothing )
174
174
timestr = Ryu. writefixed (Float64 (elapsedtime/ 1e9 ), 6 )
175
175
str = sprint () do io
176
176
if msg isa String
@@ -196,12 +196,22 @@ function time_print(io::IO, elapsedtime, bytes=0, gctime=0, allocs=0, lock_confl
196
196
end
197
197
print (io, Ryu. writefixed (Float64 (100 * gctime/ elapsedtime), 2 ), " % gc time" )
198
198
end
199
+ wall_time_sched_perc = wall_time_sched / (elapsedtime / 1e9 )
200
+ if wall_time_sched_perc > 0.1
201
+ if bytes != 0 || allocs != 0 || gctime > 0
202
+ print (io, " , " )
203
+ end
204
+ print (io, Ryu. writefixed (Float64 (100 * wall_time_sched_perc), 2 ), " % wall time scheduling" )
205
+ end
199
206
if lock_conflicts > 0
207
+ if bytes != 0 || allocs != 0 || gctime > 0 || wall_time_sched_perc > 0.1
208
+ print (io, " , " )
209
+ end
200
210
plural = lock_conflicts == 1 ? " " : " s"
201
211
print (io, " , " , lock_conflicts, " lock conflict$plural " )
202
212
end
203
213
if compile_time > 0
204
- if bytes != 0 || allocs != 0 || gctime > 0
214
+ if bytes != 0 || allocs != 0 || gctime > 0 || wall_time_sched_perc > 0.1 || lock_conflicts > 0
205
215
print (io, " , " )
206
216
end
207
217
print (io, Ryu. writefixed (Float64 (100 * compile_time/ elapsedtime), 2 ), " % compilation time" )
@@ -315,7 +325,7 @@ macro time(msg, ex)
315
325
quote
316
326
local ret = @timed $ (esc (ex))
317
327
local _msg = $ (esc (msg))
318
- time_print (stdout , ret. time* 1e9 , ret. gcstats. allocd, ret. gcstats. total_time, gc_alloc_count (ret. gcstats), ret. lock_conflicts, ret. compile_time* 1e9 , ret. recompile_time* 1e9 , true ; msg= _msg)
328
+ time_print (stdout , ret. time* 1e9 , ret. gcstats. allocd, ret. gcstats. total_time, gc_alloc_count (ret. gcstats), ret. lock_conflicts, ret. compile_time* 1e9 , ret. recompile_time* 1e9 , ret . wall_time_sched, true ; msg= _msg)
319
329
ret. value
320
330
end
321
331
end
@@ -574,13 +584,19 @@ macro timed(ex)
574
584
local elapsedtime = time_ns ()
575
585
cumulative_compile_timing (true )
576
586
local compile_elapsedtimes = cumulative_compile_time_ns ()
577
- local val = @__tryfinally ($ (esc (ex)),
578
- (elapsedtime = time_ns () - elapsedtime;
579
- cumulative_compile_timing (false );
580
- compile_elapsedtimes = cumulative_compile_time_ns () .- compile_elapsedtimes;
581
- lock_conflicts = Threads. LOCK_CONFLICT_COUNT[] - lock_conflicts;
582
- Threads. lock_profiling (false ))
583
- )
587
+ local wall_time_sched = 0.0
588
+ @with Workqueue_sched_times => zeros (UInt, Threads. maxthreadid ()) begin
589
+ sched_ts = copy (Base. Workqueue_sched_times[])
590
+ local val = @__tryfinally ($ (esc (ex)),
591
+ (elapsedtime = time_ns () - elapsedtime;
592
+ cumulative_compile_timing (false );
593
+ compile_elapsedtimes = cumulative_compile_time_ns () .- compile_elapsedtimes;
594
+ lock_conflicts = Threads. LOCK_CONFLICT_COUNT[] - lock_conflicts;
595
+ Threads. lock_profiling (false ))
596
+ )
597
+ wall_time_sched = sum (Base. Workqueue_sched_times[] .- sched_ts) / (Threads. nthreads (:interactive ) + Threads. nthreads (:default ))
598
+ end
599
+
584
600
local diff = GC_Diff (gc_num (), stats)
585
601
(
586
602
value= val,
@@ -590,7 +606,8 @@ macro timed(ex)
590
606
gcstats= diff,
591
607
lock_conflicts= lock_conflicts,
592
608
compile_time= compile_elapsedtimes[1 ]/ 1e9 ,
593
- recompile_time= compile_elapsedtimes[2 ]/ 1e9
609
+ recompile_time= compile_elapsedtimes[2 ]/ 1e9 ,
610
+ wall_time_sched= wall_time_sched/ 1e9
594
611
)
595
612
end
596
613
end
0 commit comments