# How to access the data in @timed and plot directly

**URL:** https://discourse.julialang.org/t/how-to-access-the-data-in-timed-and-plot-directly/37692
**Category:** General Usage
**Tags:** question, plotting
**Created:** [April 16, 2020, 10:24am UTC](https://discourse.julialang.org/t/how-to-access-the-data-in-timed-and-plot-directly/37692 "2020-04-16T10:24:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![A.U.M](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@A.U.M](https://discourse.julialang.org/u/A.U.M)
#### Post date: [April 16, 2020, 10:24am UTC](https://discourse.julialang.org/t/how-to-access-the-data-in-timed-and-plot-directly/37692/1 "2020-04-16T10:24:02Z")

</div>

I have implemented three functions to calculate the Fibonacci numbers like the following:

```julia
function fib(n::Integer)::BigInt
if n <= 1
n
else
fib(n-1) + fib(n-2)
end
end

```

\*\*

```julia
fib2(n::Integer)::BigInt =round(BigInt,((1+sqrt(BigFloat(5)))/2)^n / sqrt(BigFloat(5)))

```

\*\*

```julia
global cache = Dict{BigInt, BigInt}(0 => 0, 1 => 1)
function fib3(n::Integer)
global cache
if haskey(cache, n)
        cache[n]
else
cache[n] = fib3(n-1) + fib3(n-2)
end
end

```

\*\*  
How can I use the macro @timed to plot the time and memory consumption of the  
various functions to calculate Fibonacci numbers? I will be appreciated if someone can give me an example according to my code.

Updates :  
I tried to do something like this

```julia
x=[1:3] 
fib=[fib(5),fib2(5),fib3(5)]
y= [@timed fib[i] for i = 1:3]
using Plots
plot(x,y)

```

but it dosen’t work and i think the problem is how to handel ( plot ) in my case
