# HG changeset patch # User jwe # Date 1192043468 0 # Node ID 064f298f812f5023e449cd7b6ba43a7a02cc7f01 # Parent 45d6cc5a0359ad613bbb1db06c751f704097f1c7 [project @ 2007-10-10 19:11:08 by jwe] diff -r 45d6cc5a0359 -r 064f298f812f scripts/ChangeLog --- a/scripts/ChangeLog Wed Oct 10 18:51:46 2007 +0000 +++ b/scripts/ChangeLog Wed Oct 10 19:11:08 2007 +0000 @@ -1,3 +1,11 @@ +2007-10-10 Thomas Treichl + + * time/tic.m: New optional output value. + +* 2007-10-10 Thomas Treichl + + * general/int2str.m: Doc fix. + 2007-10-10 Arno Onken * statistics/distributions/hygecdf.m, diff -r 45d6cc5a0359 -r 064f298f812f scripts/general/int2str.m --- a/scripts/general/int2str.m Wed Oct 10 18:51:46 2007 +0000 +++ b/scripts/general/int2str.m Wed Oct 10 19:11:08 2007 +0000 @@ -19,8 +19,6 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} int2str (@var{n}) -## @deftypefnx {Function File} {} int2str (@var{x}, @var{precision}) -## @deftypefnx {Function File} {} int2str (@var{x}, @var{format}) ## Convert an integer to a string. This function is not very flexible. ## For better control over the results, use @code{sprintf} ## (@pxref{Formatted Output}). diff -r 45d6cc5a0359 -r 064f298f812f scripts/time/tic.m --- a/scripts/time/tic.m Wed Oct 10 18:51:46 2007 +0000 +++ b/scripts/time/tic.m Wed Oct 10 19:11:08 2007 +0000 @@ -20,7 +20,9 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} tic () ## @deftypefnx {Function File} {} toc () -## These functions set and check a wall-clock timer. For example, +## Set or check a wall-clock timer. Calling @code{tic} without an +## output argument sets the timer. Subsequent calls to @code{toc} +## return the number of seconds since the timer was set. For example, ## ## @example ## tic (); @@ -32,6 +34,16 @@ ## will set the variable @code{elapsed_time} to the number of seconds since ## the most recent call to the function @code{tic}. ## +## If called with one output argument then this function returns a scalar +## of type @code{uint64} and the wall-clock timer is not started. +## +## @example +## @group +## t = tic; sleep (5); (double (tic ()) - double (t)) * 1e-6 +## @result{} 5 +## @end group +## @end example +## ## Nested timing with @code{tic} and @code{toc} is not supported. ## Therefore @code{toc} will always return the elapsed time from the most ## recent call to @code{tic}. @@ -58,14 +70,17 @@ ## Author: jwe -function tic () +function ret = tic () if (nargin != 0) warning ("tic: ignoring extra arguments"); endif - global __tic_toc_timestamp__; - - __tic_toc_timestamp__ = clock (); + if (nargout == 1) + ret = uint64 (time () * 1e6); + else + global __tic_toc_timestamp__; + __tic_toc_timestamp__ = clock (); + endif endfunction