In Julia, I have a function that times each "kth" iteration of a for loop in the function using the @elapsed macro, and assigns such times to the variable t (and then vector time_vector). However, is there any way to write this function so that different lines within the for loop can be timed separately? I would like to time each line of the for loop, and insert the times into a two-dimensional array time_vector?
function timeloop(k)
time_vector = zeros(k)
for x = 1:k
t = @elapsed
L₁=rand(10,k) #time this line with @elapsed?
L₂=rand(k,10) #time this line with @elapsed
L₁*L₂ #time this line with #elapsed
end
time_vector[x] = t
end
time_vector
end