bugGNU Octave - Bugs: bug #54695, toc before tic


bug #54695: toc before tic

Submitted by:  Ceral Paquet <octavebugs>
Submitted on:  Wed 19 Sep 2018 07:20:13 PM UTC  
Category:  Octave Function Severity:  1 - Wish
Priority:  3 - Low Item Group:  Feature Request
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  4.4.1 Operating System:  Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Mon 24 Sep 2018 04:06:33 PM UTC, comment #7:

I also think it is probably more useful for novice to intermediate programmers to receive an error about a possibly bogus construct, rather than to: 1) return 0 (which means something) or NaN (better, because it at least says that this timing value is invalid).

There are multiple workarounds. The easiest is just to re-structure the timing code rather than putting it on one line. I write my benchmarks with bracketing tic/toc statements on separate lines and it seems clear enough.

Rik <rik5>
Project Administrator
Thu 20 Sep 2018 03:49:15 PM UTC, comment #6:

I don't see the usefulness of this, I think the certainty of the error is more helpful.

A very simple workaround is to call 'tic' in your ~/.octaverc so the internal timer is always initialized when Octave starts.

Mike Miller <mtmiller>
Project Administrator
Thu 20 Sep 2018 03:34:41 AM UTC, comment #5:

If we agree that returning 0 is better, then maybe we should have a warning that is handled as an error if in --traditional mode? Individual users may then disable the warning if they don't wish to see it.

John W. Eaton <jwe>
Project Administrator
Thu 20 Sep 2018 03:29:09 AM UTC, comment #4:


The idea would be to avoid an error over something so inconsequential. A warning or NaN (or 0) seems more appropriate.

MATLAB does error over this.

Ceral Paquet <octavebugs>
Thu 20 Sep 2018 01:28:29 AM UTC, comment #3:

So this is a request for the 'toc' function to return a value of zero elapsed time instead of issuing an error if 'tic' has not been called already? And this is not a Matlab compatibility issue, Matlab also issues an error, is that right?

Mike Miller <mtmiller>
Project Administrator
Wed 19 Sep 2018 07:31:02 PM UTC, comment #2:

Sorry that was not correct! This one.

Ceral Paquet <octavebugs>
Wed 19 Sep 2018 07:21:33 PM UTC, comment #1:
Ceral Paquet <octavebugs>
Wed 19 Sep 2018 07:20:13 PM UTC, original submission:

It has always been a minor irritation for me in MATLAB that the "toc" command errors out when called before "tic". It prevents the use of this one-liner when timing loops.

Just putting it out there as a possible divergence from MATLAB to default to the start of time (0).

Ceral Paquet <octavebugs>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by octavebugs (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-09-24 rik5 Priority5 - Normal => 3 - Low
    2018-09-20 mtmiller CategoryNone => Octave Function
        Severity3 - Normal => 1 - Wish

    Back to the top

    Powered by Savane 3.4