home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fb.zip / octave / SCRIPTS.ZIP / scripts / miscellaneous / tic.m < prev    next >
Text File  |  1999-12-15  |  2KB  |  68 lines

  1. ## Copyright (C) 1996, 1997 John W. Eaton
  2. ##
  3. ## This file is part of Octave.
  4. ##
  5. ## Octave is free software; you can redistribute it and/or modify it
  6. ## under the terms of the GNU General Public License as published by
  7. ## the Free Software Foundation; either version 2, or (at your option)
  8. ## any later version.
  9. ##
  10. ## Octave is distributed in the hope that it will be useful, but
  11. ## WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. ## General Public License for more details.
  14. ##
  15. ## You should have received a copy of the GNU General Public License
  16. ## along with Octave; see the file COPYING.  If not, write to the Free
  17. ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  18. ## 02111-1307, USA.
  19.  
  20. ## -*- texinfo -*-
  21. ## @deftypefn {Function File} {} tic ()
  22. ## @deftypefnx {Function File} {} toc ()
  23. ## These functions set and check a wall-clock timer.  For example,
  24. ## 
  25. ## @example
  26. ## tic ();
  27. ## # many computations later...
  28. ## elapsed_time = toc ();
  29. ## @end example
  30. ## 
  31. ## @noindent
  32. ## will set the variable @code{elapsed_time} to the number of seconds since
  33. ## the most recent call to the function @code{tic}.
  34. ## 
  35. ## If you are more interested in the CPU time that your process used, you
  36. ## should use the @code{cputime} function instead.  The @code{tic} and
  37. ## @code{toc} functions report the actual wall clock time that elapsed
  38. ## between the calls.  This may include time spent processing other jobs or
  39. ## doing nothing at all.  For example,
  40. ## 
  41. ## @example
  42. ## @group
  43. ## tic (); sleep (5); toc ()
  44. ##      @result{} 5
  45. ## t = cputime (); sleep (5); cputime () - t
  46. ##      @result{} 0
  47. ## @end group
  48. ## @end example
  49. ## 
  50. ## @noindent
  51. ## (This example also illustrates that the CPU timer may have a fairly
  52. ## coarse resolution.)
  53. ## @end deftypefn
  54.  
  55. ## Author: jwe
  56.  
  57. function tic ()
  58.  
  59.   if (nargin != 0)
  60.     warning ("tic: ignoring extra arguments");
  61.   endif
  62.  
  63.   global __tic_toc_timestamp__;
  64.  
  65.   __tic_toc_timestamp__ = clock ();
  66.  
  67. endfunction
  68.