changeset 7005:064f298f812f

[project @ 2007-10-10 19:11:08 by jwe]
author jwe
date Wed, 10 Oct 2007 19:11:08 +0000
parents 45d6cc5a0359
children 039ef140ac35
files scripts/ChangeLog scripts/general/int2str.m scripts/time/tic.m
diffstat 3 files changed, 28 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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  <Thomas.Treichl@gmx.net>
+
+	* time/tic.m: New optional output value.
+
+* 2007-10-10  Thomas Treichl  <Thomas.Treichl@gmx.net>
+
+	* general/int2str.m: Doc fix.
+
 2007-10-10  Arno Onken  <asnelt@asnelt.org>
 
 	* statistics/distributions/hygecdf.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}). 
--- 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