# Why Optim.seconds(res) does not exist?

**URL:** https://discourse.julialang.org/t/why-optim-seconds-res-does-not-exist/83123
**Category:** Optimization (Mathematical)
**Tags:** optim
**Created:** [June 21, 2022, 1:18pm UTC](https://discourse.julialang.org/t/why-optim-seconds-res-does-not-exist/83123 "2022-06-21T13:18:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![axel365](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/axel365/32/36027_2.png) [@axel365](https://discourse.julialang.org/u/axel365)
#### Post date: [June 21, 2022, 1:18pm UTC](https://discourse.julialang.org/t/why-optim-seconds-res-does-not-exist/83123/1 "2022-06-21T13:18:52Z")

</div>

Almost all is in the title… With Optim.jl, wouldn’t it be useful to have a function that can access the number of seconds run for an optimization problem? If this exists already, i did not find it.

---

<div class="post-metadata">

### Author: ![skleinbo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skleinbo/32/36080_2.png) [@skleinbo](https://discourse.julialang.org/u/skleinbo)
#### Post date: [June 21, 2022, 1:29pm UTC](https://discourse.julialang.org/t/why-optim-seconds-res-does-not-exist/83123/2 "2022-06-21T13:29:06Z")

</div>

I think you want `time_run`.

```julia
julia> f(x) = (sum(x)-1)^2
f (generic function with 1 method)

julia> sol = optimize(f, rand(100), GradientDescent())
 * Status: success

[...]

julia> Optim.time_run(sol)
2.7894973754882812e-5

```

It’s not exported though and thus needs to be accessed with `Optim.time_run` or imported explicitly.
