You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using TimerOutputs, Base.Threads
function parallel_task()
to = TimerOutput()
# define the loop to be run in parallel
@threads for i in 1:10
# measure the execution time of each loop iteration using @timeit
@timeit to "within threads" begin
# perform some time-consuming task here
sleep(rand())
end
end
# print the timing results
to
end
Would produce result like
─────────────────────────────────────────────────────────────────────────────────────
Time Allocations
─────────────────────── ────────────────────────
Tot / % measured: 1.64s / 16.4% 2.77MiB / 0.3%
Section ncalls time %tot avg alloc %tot avg
─────────────────────────────────────────────────────────────────────────────────────
within threads 1 270ms 100.0% 270ms 9.86KiB 100.0% 9.86KiB
within threads 1 335ms 124.1% 335ms 439KiB 4447.7% 439KiB
within threads 2 1.58s 586.1% 791ms 1.53MiB 15867.6% 782KiB
within threads 1 273ms 100.9% 273ms 13.0KiB 131.5% 13.0KiB
within threads 4 2.31s 857.0% 579ms 2.77MiB 28808.8% 710KiB
within threads 1 545ms 201.9% 545ms 862KiB 8740.7% 862KiB
─────────────────────────────────────────────────────────────────────────────────────
I guess the issue is because multi-threads messed up with "previous_timer" and "timer_stack".
The text was updated successfully, but these errors were encountered:
Would produce result like
I guess the issue is because multi-threads messed up with "previous_timer" and "timer_stack".
The text was updated successfully, but these errors were encountered: