Plot using @timed

Didn’t you ask that already here? How to access the data in @timed and plot directly

First you have an issue, you declare a function fib then declare fib as an array…so things go weird. If I rename your function to fib1 things work better…

This might not be the most elegant way of doing this but:

function record(f, a)
    val, time, bytes, gctime, memallocs = @timed f(a)
    (time=time, bytes=bytes, gctime=gctime, memallocs=memallocs)
end

x=[1:3]
fib=[fib1, fib2, fib3]
y= [record(fib[i], 10).time for i = 1:3]
using Plots
plot(x,y)

If you want bytes you can change .time to .bytes when setting Y.

1 Like