Alternative to tic() and toc()



What’s an easy-to-type alternative to tic() and toc(), for timing a sequence of commands (or anything else, really), which are disappearing soon?

Sort of like this:

julia-0.6> t = now()

julia-0.6> Dates.canonicalize(Dates.CompoundPeriod(now() - t))
29 seconds, 800 milliseconds

only easier to type.


The proper way would be to use BenchmarkTools.jl and @btime.
If you are only interested in one off runtime @time and its siblings are useful.


But I don’t want to benchmark Julia code, I want an easy way to time how long things take. tic() and toc() are easy to type and remember…


You can wrap in a begin-end block:

@time begin

Or use something like for timing several things and pretty print it.


Someone could add the old tic / toc / toq functions from Base to the MatlabCompat package.


Thanks, Stefan. In fact, I don’t need anything else from MATLAB so I’m happy with a separate package for my own purposes. :slight_smile: