You can install any package with Pkg.add
. In this case, you just need to run
Pkg.add("TimerOutputs")
Julia is a little different from systems like MATLAB in that you will need to install packages even to do simple tasks.
If you don’t want to use any packages, then I think that the solution that I gave above should work for you. You might also like these functions/macros:
help?> tic
search: tic tick_params ticklabel_format zticks yticks xticks issticky
tic()
Set a timer to be read by the next call to toc or toq. The macro call @time
expr can also be used to time evaluation.
julia> tic()
0x0000c45bc7abac95
julia> sleep(0.3)
julia> toc()
elapsed time: 0.302745944 seconds
0.302745944
help?> toc
search: toc touch autoscale getsockname trylock TCPSocket bitbroadcast
toc()
Print and return the time elapsed since the last tic. The macro call @time
expr can also be used to time evaluation.
julia> tic()
0x0000c45bc7abac95
julia> sleep(0.3)
julia> toc()
elapsed time: 0.302745944 seconds
0.302745944
help?> @allocated
@allocated
A macro to evaluate an expression, discarding the resulting value, instead
returning the total number of bytes allocated during evaluation of the
expression. Note: the expression is evaluated inside a local function,
instead of the current context, in order to eliminate the effects of
compilation, however, there still may be some allocations due to JIT
compilation. This also makes the results inconsistent with the @time macros,
which do not try to adjust for the effects of compilation.
See also @time, @timev, @timed, and @elapsed.
julia> @allocated rand(10^6)
8000080
help?> @timed
@timed
A macro to execute an expression, and return the value of the expression,
elapsed time, total bytes allocated, garbage collection time, and an object
with various memory allocation counters.
See also @time, @timev, @elapsed, and @allocated.
julia> val, t, bytes, gctime, memallocs = @timed rand(10^6);
julia> t
0.006634834
julia> bytes
8000256
julia> gctime
0.0055765
julia> fieldnames(typeof(memallocs))
9-element Array{Symbol,1}:
:allocd
:malloc
:realloc
:poolalloc
:bigalloc
:freecall
:total_time
:pause
:full_sweep
julia> memallocs.total_time
5576500