Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate tic and toc #17046

Closed
dpsanders opened this issue Jun 21, 2016 · 14 comments
Closed

Deprecate tic and toc #17046

dpsanders opened this issue Jun 21, 2016 · 14 comments
Labels
kind:deprecation This change introduces or involves a deprecation needs decision A decision on this change is needed
Milestone

Comments

@dpsanders
Copy link
Contributor

I suggest that we should deprecate tic and toc and explain that @elapsed or one of the @time family should be used instead.

@ivarne
Copy link
Sponsor Member

ivarne commented Jun 21, 2016

-1 Deprecation of a warm welcome to matlab users?

How about rather add a tip to toc reccomending @time and @elapsed in Julia as superior timing facilities?

julia> tic();
julia> toc();
elapest time: 2.123456 seconds
    You should also try the @time and @elapsed macros for timing in Julia

@tkelman
Copy link
Contributor

tkelman commented Jun 21, 2016

The macros can't replace tic and toc in all usage, e.g. tic(); using Compat; toc(). Maybe

julia> @time using Compat                                                                                                  
ERROR: unsupported or misplaced expression using

could be fixed though?

@nalimilan
Copy link
Member

@ivarne They are especially a problem for MATLAB users who use them incorrectly do run benchmarks in the global scope. :-)

Anyway, MATLABisms should go to MATLAB.jl, the only argument for keeping tic and toc would be that they make sense in Julia itself (which @tkelman's comment seems to indicate).

@ivarne
Copy link
Sponsor Member

ivarne commented Jun 21, 2016

PS: @nalimilan I don't think you meant MATLAB.jl (Source)

The MATLAB.jl package provides an interface for using MATLAB™ from the Julia language. You cannot use MATLAB.jl without having purchased and installed a copy of MATLAB™ from MathWorks. This package is available free of charge and in no way replaces or alters any functionality of MathWorks's MATLAB product.

I agree that tic and toc isn't ideal for use in Julia. The problem is that many users don't read the manual, and someone with matlab experience will try tic\toc before looking. That is a great time to give the answer they expect, and suggest better benchmarking methods. (A UndefVarError is not a nice experience)

@ivarne
Copy link
Sponsor Member

ivarne commented Jun 21, 2016

Another option will naturally be to override printing of UndefVarError for tic and toc in the REPL to give proper guidance to the better methods.

@nalimilan
Copy link
Member

@ivarne Sorry, I meant MatlabCompat.jl.

@ufechner7
Copy link

Coming from Python, I love tic() and toc() a lot. Easy and intuitive!

@tknopp
Copy link
Contributor

tknopp commented Jun 22, 2016

@ivarne: This is a very good suggestion, but could be applied to various other functions as well. Thus it might be good to provide a more general framework here, where a list of "common" functions from other languages is parsed.

Personally, I would not see an urgent need to remove these two particular functions. But this is quite subjective of course.

@Glen-O
Copy link

Glen-O commented Aug 14, 2016

Oftentimes, in my MATLAB code, I use tic and toc to allow me to have the code output the time since a certain point in the code, in order to be able to easily keep track of run time mid-run.

Sure, it can be done in julia using time() and storing the "tic" time and then subtracting it from the time where I want to "toc", but tic/toc makes it much cleaner.

So rather than deprecating tic and toc, I'd actually like to see them extended slightly. Right now, you can only have one toc/toq per tic. It would be nice if you could reuse the existing tic until a new tic is set, perhaps with "tok()"? (for "toc keep", much as toq is "toc quiet")

@Keno Keno added this to the 1.0 milestone Aug 18, 2017
@StefanKarpinski StefanKarpinski added good first issue Indicates a good issue for first-time contributors to Julia status:help wanted Indicates that a maintainer wants help on an issue or pull request needs decision A decision on this change is needed and removed good first issue Indicates a good issue for first-time contributors to Julia status:help wanted Indicates that a maintainer wants help on an issue or pull request labels Aug 24, 2017
@Keno
Copy link
Member

Keno commented Aug 24, 2017

From triage: Let's deprecate these methods and put them into MatlabCompat for people who are used to them from MATLAB. They are unintuitive for people who don't know them and the fact that they have global state makes them pretty much useless anywhere but the REPL.

@StefanKarpinski
Copy link
Sponsor Member

StefanKarpinski commented Aug 24, 2017

Right – the global state is a disaster in combination with threading.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Aug 24, 2017

the fact that they have global state

just fwiw, they don't have global state, and have no issues at all being used with threading.

@Keno
Copy link
Member

Keno commented Aug 24, 2017

Ah, it's task-local?

@StefanKarpinski
Copy link
Sponsor Member

Ah, yeah, that's true. The original implementation used a global array – I was thinking of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:deprecation This change introduces or involves a deprecation needs decision A decision on this change is needed
Projects
None yet
Development

No branches or pull requests