Reputation: 533
I have a custom function and I would like to evaluate its media performance. For this, I would like to loop by executing my function a certain number of times. I want to do this because I see that the runtime is very unstable.
A typical execution measuring the execution time would look something like this
@time my_function()
or
@time begin
my_function()
end
In this particular case, I only visualize the execution time, but I don't know how to register the execution time to allocate the time for each iteration in a vector. For example, I would like something like this
vector_time = 1:100
for i in 1:100
@time my_function()
vector_time[i] = get_time_i # register the time of the i-th iteration
end
Upvotes: 1
Views: 1904
Reputation: 91
If you are timing multiple sections of your code at once, you can also use TimerOutputs.jl, which I've found to be very convenient. It automatically computes average runtimes and % total runtime.
Upvotes: 1