Stopwatch function in Julia
MATLAB has a couple of functions tic
and toc
which can be used to start and stop the stopwatch timer. Example taken from link :
tic A = rand(12000, 4400); B = rand(12000, 4400); toc C = A'.*B'; toc
I know Julia has a macro @time
that has similar functionality.
julia> @time [sin(cos(i)) for i in 1:100000];
elapsed time: 0.00721026 seconds (800048 bytes allocated)
Does Julia have many of these features? The macro @time
works well for sync statements that can be written in one or two lines. For longer pieces of code, I would rather use the tic-toc functions.
What i tried
When I googled "julia stopwatch" I found one helpful link and four unrelated links.
- Introducing Julia / Metaprogramming - Wikibooks, open ... Meta-programming is when you write Julia's code to process and modify Julia's code .... The @time macro inserts a "start stopwatch" command at the beginning ...
- Our invisible stopwatch promo - YouTube Videos for julia stopwatch
- Julia Larson on Twitter: "This OSX #Mac timer / stopwatch is ...
- Timed episodes of a French chef with a stopwatch
- julia griffith | Oiselle Running Apparel for women
I don't know why I didn't think to just try tic()
and toc()
.
source to share
From Julia's search documentation
tic()
Set the timer for reading with the next call
toc()
ortoq()
. calling a macro@time expr
can also be used to estimate time.
source to share