Mercurial > hg > octave-lyh
diff src/data.cc @ 7065:97db94ae2cf0
[project @ 2007-10-25 05:50:55 by jwe]
author | jwe |
---|---|
date | Thu, 25 Oct 2007 05:50:56 +0000 |
parents | 271fa61d8fae |
children | 405cf85b435c |
line wrap: on
line diff
--- a/src/data.cc +++ b/src/data.cc @@ -2964,7 +2964,7 @@ BINARY_OP_DEFUN_BODY (op_el_or); } -static double __tic_toc_timestamp__ = -1.0; +static double tic_toc_timestamp = -1.0; DEFUN (tic, args, nargout, "-*- texinfo -*-\n\ @@ -3019,15 +3019,20 @@ @end deftypefn") { octave_value retval; + int nargin = args.length (); if (nargin != 0) warning ("tic: ignoring extra arguments"); + octave_time now; + + double tmp = now.double_value (); + if (nargout > 0) - retval = static_cast<octave_uint64> (static_cast<double> (octave_time ()) * 1.0e6); + retval = static_cast<octave_uint64> (1e6 * tmp); else - __tic_toc_timestamp__= static_cast<double>(octave_time ()); + tic_toc_timestamp = tmp; return retval; } @@ -3038,24 +3043,30 @@ See tic.\n\ @end deftypefn") { - double sec = static_cast<double>(octave_time ()); octave_value retval; + int nargin = args.length (); if (nargin != 0) warning ("tic: ignoring extra arguments"); - if (__tic_toc_timestamp__ < 0) + if (tic_toc_timestamp < 0) { warning ("toc called before timer set"); if (nargout > 0) - retval = Matrix(); + retval = Matrix (); } - else if (nargout > 0) - retval = sec - __tic_toc_timestamp__; else - octave_stdout << "Elapsed time is " << sec - __tic_toc_timestamp__ - << " seconds.\n"; + { + octave_time now; + + double tmp = now.double_value () - tic_toc_timestamp; + + if (nargout > 0) + retval = tmp; + else + octave_stdout << "Elapsed time is " << tmp << " seconds.\n"; + } return retval; }