I was wondering if there was a macro out there similar to @time, but that shows the timer update in real time. Anyone know one?
The use case is that I’ve got some pretty expensive functions and it would be good to be able to glimpse at the screen and figure out that one of them hasn’t progressed in a long time. So if the terminal could show real elapsed time while the timer is running, that would be ideal.
The alternative is to print the time when the function started and then look at the clock, but that’s not as nice.
Thanks a lot!
I once made a package that did a bit of timing… It might still work:
julia> using TickTock julia> tick() [ Info: started timer at: 2021-04-16T13:54:20.094 julia> tick() [ Info: started timer at: 2021-04-16T13:54:22.932 julia> tick() [ Info: started timer at: 2021-04-16T13:54:25.362 julia> TickTock.showtimes() 3 [ Info: 2.895372181s: 2 seconds, 895 milliseconds 2 [ Info: 5.325055601s: 5 seconds, 325 milliseconds 1 [ Info: 8.179692675s: 8 seconds, 179 milliseconds julia> TickTock.showtimes() 3 [ Info: 5.505053393s: 5 seconds, 505 milliseconds 2 [ Info: 7.934736813s: 7 seconds, 934 milliseconds 1 [ Info: 10.789373887s: 10 seconds, 789 milliseconds
Hopefully something better will come along soon.
There’s https://github.com/timholy/ProgressMeter.jl which has a
@showprogress macro which can make progress bars in the terminal like
Computing initial pass...53%|███████████████████████████ | ETA: 0:09:02
It’s pretty nice!
@cormullion Yeah, displaying the start time was the easy alternative (and I am currently doing it with
Dates.now(), but I was wondering if there was a nicer solution.
@ericphanson Those are pretty cool, but I was looking for something decoupled from a for loop. One of the functions I call which often hangs is a linear system solver, which comes from a package and depends on residuals, so it’s not a clear
for i in 1:10 type of thing.
If anyone knows a package that shows something like a running timer, that’d be great.
Both those packages support lots of custom control. As an example from the ProgressMeters README,
function my_long_running_function(filenames::Array) n = length(filenames) p = Progress(n, 1) # minimum update interval: 1 second for f in filenames # Here's where you do all the hard, slow work next!(p) end end
next!(p) could be called anywhere, e.g. from inside a recursive function. There’s a lot more options too, I encourage you to check out the docs.