Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 3e60ff9d4d6f58c8fbd17208f14089fa > files > 429

octave-doc-3.2.3-3mdv2010.0.i586.rpm

<html lang="en">
<head>
<title>Timing Utilities - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="System-Utilities.html#System-Utilities" title="System Utilities">
<link rel="next" href="Filesystem-Utilities.html#Filesystem-Utilities" title="Filesystem Utilities">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Timing-Utilities"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Filesystem-Utilities.html#Filesystem-Utilities">Filesystem Utilities</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="System-Utilities.html#System-Utilities">System Utilities</a>
<hr>
</div>

<h3 class="section">34.1 Timing Utilities</h3>

<p>Octave's core set of functions for manipulating time values are
patterned after the corresponding functions from the standard C library. 
Several of these functions use a data structure for time that includes
the following elements:

     <dl>
<dt><code>usec</code><dd>Microseconds after the second (0-999999).

     <br><dt><code>sec</code><dd>Seconds after the minute (0-61).  This number can be 61 to account
for leap seconds.

     <br><dt><code>min</code><dd>Minutes after the hour (0-59).

     <br><dt><code>hour</code><dd>Hours since midnight (0-23).

     <br><dt><code>mday</code><dd>Day of the month (1-31).

     <br><dt><code>mon</code><dd>Months since January (0-11).

     <br><dt><code>year</code><dd>Years since 1900.

     <br><dt><code>wday</code><dd>Days since Sunday (0-6).

     <br><dt><code>yday</code><dd>Days since January 1 (0-365).

     <br><dt><code>isdst</code><dd>Daylight Savings Time flag.

     <br><dt><code>zone</code><dd>Time zone. 
</dl>

<p class="noindent">In the descriptions of the following functions, this structure is
referred to as a <var>tm_struct</var>.

<!-- ./DLD-FUNCTIONS/time.cc -->
   <p><a name="doc_002dtime"></a>

<div class="defun">
&mdash; Loadable Function:  <b>time</b> ()<var><a name="index-time-2268"></a></var><br>
<blockquote><p>Return the current time as the number of seconds since the epoch.  The
epoch is referenced to 00:00:00 CUT (Coordinated Universal Time) 1 Jan
1970.  For example, on Monday February 17, 1997 at 07:15:06 CUT, the
value returned by <code>time</code> was 856163706. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dstrftime.html#doc_002dstrftime">strftime</a>, <a href="doc_002dstrptime.html#doc_002dstrptime">strptime</a>, <a href="doc_002dlocaltime.html#doc_002dlocaltime">localtime</a>, <a href="doc_002dgmtime.html#doc_002dgmtime">gmtime</a>, <a href="doc_002dmktime.html#doc_002dmktime">mktime</a>, <a href="doc_002dnow.html#doc_002dnow">now</a>, <a href="doc_002ddate.html#doc_002ddate">date</a>, <a href="doc_002dclock.html#doc_002dclock">clock</a>, <a href="doc_002ddatenum.html#doc_002ddatenum">datenum</a>, <a href="doc_002ddatestr.html#doc_002ddatestr">datestr</a>, <a href="doc_002ddatevec.html#doc_002ddatevec">datevec</a>, <a href="doc_002dcalendar.html#doc_002dcalendar">calendar</a>, <a href="doc_002dweekday.html#doc_002dweekday">weekday</a>. 
</p></blockquote></div>

<!-- ./time/now.m -->
   <p><a name="doc_002dnow"></a>

<div class="defun">
&mdash; Function File: t = <b>now</b> ()<var><a name="index-now-2269"></a></var><br>
<blockquote><p>Returns the current local time as the number of days since Jan 1, 0000. 
By this reckoning, Jan 1, 1970 is day number 719529.

        <p>The integral part, <code>floor (now)</code> corresponds to 00:00:00 today.

        <p>The fractional part, <code>rem (now, 1)</code> corresponds to the current
time on Jan 1, 0000.

        <p>The returned value is also called a "serial date number"
(see <code>datenum</code>). 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dclock.html#doc_002dclock">clock</a>, <a href="doc_002ddate.html#doc_002ddate">date</a>, <a href="doc_002ddatenum.html#doc_002ddatenum">datenum</a>. 
</p></blockquote></div>

<!-- ./time/ctime.m -->
   <p><a name="doc_002dctime"></a>

<div class="defun">
&mdash; Function File:  <b>ctime</b> (<var>t</var>)<var><a name="index-ctime-2270"></a></var><br>
<blockquote><p>Convert a value returned from <code>time</code> (or any other non-negative
integer), to the local time and return a string of the same form as
<code>asctime</code>.  The function <code>ctime (time)</code> is equivalent to
<code>asctime (localtime (time))</code>.  For example,

     <pre class="example">          ctime (time ())
               &rArr; "Mon Feb 17 01:15:06 1997\n"
</pre>
        </blockquote></div>

<!-- ./DLD-FUNCTIONS/time.cc -->
   <p><a name="doc_002dgmtime"></a>

<div class="defun">
&mdash; Loadable Function:  <b>gmtime</b> (<var>t</var>)<var><a name="index-gmtime-2271"></a></var><br>
<blockquote><p>Given a value returned from time (or any non-negative integer),
return a time structure corresponding to CUT.  For example,

     <pre class="example">          gmtime (time ())
               &rArr; {
                     usec = 0
                     year = 97
                     mon = 1
                     mday = 17
                     sec = 6
                     zone = CST
                     min = 15
                     wday = 1
                     hour = 7
                     isdst = 0
                     yday = 47
                   }
</pre>
        <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002dstrftime.html#doc_002dstrftime">strftime</a>, <a href="doc_002dstrptime.html#doc_002dstrptime">strptime</a>, <a href="doc_002dlocaltime.html#doc_002dlocaltime">localtime</a>, <a href="doc_002dmktime.html#doc_002dmktime">mktime</a>, <a href="doc_002dtime.html#doc_002dtime">time</a>, <a href="doc_002dnow.html#doc_002dnow">now</a>, <a href="doc_002ddate.html#doc_002ddate">date</a>, <a href="doc_002dclock.html#doc_002dclock">clock</a>, <a href="doc_002ddatenum.html#doc_002ddatenum">datenum</a>, <a href="doc_002ddatestr.html#doc_002ddatestr">datestr</a>, <a href="doc_002ddatevec.html#doc_002ddatevec">datevec</a>, <a href="doc_002dcalendar.html#doc_002dcalendar">calendar</a>, <a href="doc_002dweekday.html#doc_002dweekday">weekday</a>. 
</p></blockquote></div>

<!-- ./DLD-FUNCTIONS/time.cc -->
   <p><a name="doc_002dlocaltime"></a>

<div class="defun">
&mdash; Loadable Function:  <b>localtime</b> (<var>t</var>)<var><a name="index-localtime-2272"></a></var><br>
<blockquote><p>Given a value returned from time (or any non-negative integer),
return a time structure corresponding to the local time zone.

     <pre class="example">          localtime (time ())
               &rArr; {
                     usec = 0
                     year = 97
                     mon = 1
                     mday = 17
                     sec = 6
                     zone = CST
                     min = 15
                     wday = 1
                     hour = 1
                     isdst = 0
                     yday = 47
                   }
</pre>
        <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002dstrftime.html#doc_002dstrftime">strftime</a>, <a href="doc_002dstrptime.html#doc_002dstrptime">strptime</a>, <a href="doc_002dgmtime.html#doc_002dgmtime">gmtime</a>, <a href="doc_002dmktime.html#doc_002dmktime">mktime</a>, <a href="doc_002dtime.html#doc_002dtime">time</a>, <a href="doc_002dnow.html#doc_002dnow">now</a>, <a href="doc_002ddate.html#doc_002ddate">date</a>, <a href="doc_002dclock.html#doc_002dclock">clock</a>, <a href="doc_002ddatenum.html#doc_002ddatenum">datenum</a>, <a href="doc_002ddatestr.html#doc_002ddatestr">datestr</a>, <a href="doc_002ddatevec.html#doc_002ddatevec">datevec</a>, <a href="doc_002dcalendar.html#doc_002dcalendar">calendar</a>, <a href="doc_002dweekday.html#doc_002dweekday">weekday</a>. 
</p></blockquote></div>

<!-- ./DLD-FUNCTIONS/time.cc -->
   <p><a name="doc_002dmktime"></a>

<div class="defun">
&mdash; Loadable Function:  <b>mktime</b> (<var>tm_struct</var>)<var><a name="index-mktime-2273"></a></var><br>
<blockquote><p>Convert a time structure corresponding to the local time to the number
of seconds since the epoch.  For example,

     <pre class="example">          mktime (localtime (time ()))
               &rArr; 856163706
</pre>
        <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002dstrftime.html#doc_002dstrftime">strftime</a>, <a href="doc_002dstrptime.html#doc_002dstrptime">strptime</a>, <a href="doc_002dlocaltime.html#doc_002dlocaltime">localtime</a>, <a href="doc_002dgmtime.html#doc_002dgmtime">gmtime</a>, <a href="doc_002dtime.html#doc_002dtime">time</a>, <a href="doc_002dnow.html#doc_002dnow">now</a>, <a href="doc_002ddate.html#doc_002ddate">date</a>, <a href="doc_002dclock.html#doc_002dclock">clock</a>, <a href="doc_002ddatenum.html#doc_002ddatenum">datenum</a>, <a href="doc_002ddatestr.html#doc_002ddatestr">datestr</a>, <a href="doc_002ddatevec.html#doc_002ddatevec">datevec</a>, <a href="doc_002dcalendar.html#doc_002dcalendar">calendar</a>, <a href="doc_002dweekday.html#doc_002dweekday">weekday</a>. 
</p></blockquote></div>

<!-- ./time/asctime.m -->
   <p><a name="doc_002dasctime"></a>

<div class="defun">
&mdash; Function File:  <b>asctime</b> (<var>tm_struct</var>)<var><a name="index-asctime-2274"></a></var><br>
<blockquote><p>Convert a time structure to a string using the following five-field
format: Thu Mar 28 08:40:14 1996.  For example,

     <pre class="example">          asctime (localtime (time ()))
               &rArr; "Mon Feb 17 01:15:06 1997\n"
</pre>
        <p>This is equivalent to <code>ctime (time ())</code>. 
</p></blockquote></div>

<!-- ./DLD-FUNCTIONS/time.cc -->
   <p><a name="doc_002dstrftime"></a>

<div class="defun">
&mdash; Loadable Function:  <b>strftime</b> (<var>fmt, tm_struct</var>)<var><a name="index-strftime-2275"></a></var><br>
<blockquote><p>Format the time structure <var>tm_struct</var> in a flexible way using the
format string <var>fmt</var> that contains &lsquo;<samp><span class="samp">%</span></samp>&rsquo; substitutions
similar to those in <code>printf</code>.  Except where noted, substituted
fields have a fixed size; numeric fields are padded if necessary. 
Padding is with zeros by default; for fields that display a single
number, padding can be changed or inhibited by following the &lsquo;<samp><span class="samp">%</span></samp>&rsquo;
with one of the modifiers described below.  Unknown field specifiers are
copied as normal characters.  All other characters are copied to the
output without change.  For example,

     <pre class="example">          strftime ("%r (%Z) %A %e %B %Y", localtime (time ()))
               &rArr; "01:15:06 AM (CST) Monday 17 February 1997"
</pre>
        <p>Octave's <code>strftime</code> function supports a superset of the ANSI C
field specifiers.

     <p class="noindent">Literal character fields:

          <dl>
<dt><code>%</code><dd>% character.

          <br><dt><code>n</code><dd>Newline character.

          <br><dt><code>t</code><dd>Tab character. 
</dl>

     <p class="noindent">Numeric modifiers (a nonstandard extension):

          <dl>
<dt><code>- (dash)</code><dd>Do not pad the field.

          <br><dt><code>_ (underscore)</code><dd>Pad the field with spaces. 
</dl>

     <p class="noindent">Time fields:

          <dl>
<dt><code>%H</code><dd>Hour (00-23).

          <br><dt><code>%I</code><dd>Hour (01-12).

          <br><dt><code>%k</code><dd>Hour (0-23).

          <br><dt><code>%l</code><dd>Hour (1-12).

          <br><dt><code>%M</code><dd>Minute (00-59).

          <br><dt><code>%p</code><dd>Locale's AM or PM.

          <br><dt><code>%r</code><dd>Time, 12-hour (hh:mm:ss [AP]M).

          <br><dt><code>%R</code><dd>Time, 24-hour (hh:mm).

          <br><dt><code>%s</code><dd>Time in seconds since 00:00:00, Jan 1, 1970 (a nonstandard extension).

          <br><dt><code>%S</code><dd>Second (00-61).

          <br><dt><code>%T</code><dd>Time, 24-hour (hh:mm:ss).

          <br><dt><code>%X</code><dd>Locale's time representation (%H:%M:%S).

          <br><dt><code>%Z</code><dd>Time zone (EDT), or nothing if no time zone is determinable. 
</dl>

     <p class="noindent">Date fields:

          <dl>
<dt><code>%a</code><dd>Locale's abbreviated weekday name (Sun-Sat).

          <br><dt><code>%A</code><dd>Locale's full weekday name, variable length (Sunday-Saturday).

          <br><dt><code>%b</code><dd>Locale's abbreviated month name (Jan-Dec).

          <br><dt><code>%B</code><dd>Locale's full month name, variable length (January-December).

          <br><dt><code>%c</code><dd>Locale's date and time (Sat Nov 04 12:02:33 EST 1989).

          <br><dt><code>%C</code><dd>Century (00-99).

          <br><dt><code>%d</code><dd>Day of month (01-31).

          <br><dt><code>%e</code><dd>Day of month ( 1-31).

          <br><dt><code>%D</code><dd>Date (mm/dd/yy).

          <br><dt><code>%h</code><dd>Same as %b.

          <br><dt><code>%j</code><dd>Day of year (001-366).

          <br><dt><code>%m</code><dd>Month (01-12).

          <br><dt><code>%U</code><dd>Week number of year with Sunday as first day of week (00-53).

          <br><dt><code>%w</code><dd>Day of week (0-6).

          <br><dt><code>%W</code><dd>Week number of year with Monday as first day of week (00-53).

          <br><dt><code>%x</code><dd>Locale's date representation (mm/dd/yy).

          <br><dt><code>%y</code><dd>Last two digits of year (00-99).

          <br><dt><code>%Y</code><dd>Year (1970-). 
</dl>
        <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dstrptime.html#doc_002dstrptime">strptime</a>, <a href="doc_002dlocaltime.html#doc_002dlocaltime">localtime</a>, <a href="doc_002dgmtime.html#doc_002dgmtime">gmtime</a>, <a href="doc_002dmktime.html#doc_002dmktime">mktime</a>, <a href="doc_002dtime.html#doc_002dtime">time</a>, <a href="doc_002dnow.html#doc_002dnow">now</a>, <a href="doc_002ddate.html#doc_002ddate">date</a>, <a href="doc_002dclock.html#doc_002dclock">clock</a>, <a href="doc_002ddatenum.html#doc_002ddatenum">datenum</a>, <a href="doc_002ddatestr.html#doc_002ddatestr">datestr</a>, <a href="doc_002ddatevec.html#doc_002ddatevec">datevec</a>, <a href="doc_002dcalendar.html#doc_002dcalendar">calendar</a>, <a href="doc_002dweekday.html#doc_002dweekday">weekday</a>. 
</p></blockquote></div>

<!-- ./DLD-FUNCTIONS/time.cc -->
   <p><a name="doc_002dstrptime"></a>

<div class="defun">
&mdash; Loadable Function: [<var>tm_struct</var>, <var>nchars</var>] = <b>strptime</b> (<var>str, fmt</var>)<var><a name="index-strptime-2276"></a></var><br>
<blockquote><p>Convert the string <var>str</var> to the time structure <var>tm_struct</var> under
the control of the format string <var>fmt</var>.

        <p>If <var>fmt</var> fails to match, <var>nchars</var> is 0; otherwise it is set to the
position of last matched character plus 1. Always check for this unless
you're absolutely sure the date string will be parsed correctly. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dstrftime.html#doc_002dstrftime">strftime</a>, <a href="doc_002dlocaltime.html#doc_002dlocaltime">localtime</a>, <a href="doc_002dgmtime.html#doc_002dgmtime">gmtime</a>, <a href="doc_002dmktime.html#doc_002dmktime">mktime</a>, <a href="doc_002dtime.html#doc_002dtime">time</a>, <a href="doc_002dnow.html#doc_002dnow">now</a>, <a href="doc_002ddate.html#doc_002ddate">date</a>, <a href="doc_002dclock.html#doc_002dclock">clock</a>, <a href="doc_002ddatenum.html#doc_002ddatenum">datenum</a>, <a href="doc_002ddatestr.html#doc_002ddatestr">datestr</a>, <a href="doc_002ddatevec.html#doc_002ddatevec">datevec</a>, <a href="doc_002dcalendar.html#doc_002dcalendar">calendar</a>, <a href="doc_002dweekday.html#doc_002dweekday">weekday</a>. 
</p></blockquote></div>

   <p>Most of the remaining functions described in this section are not
patterned after the standard C library.  Some are available for
compatibility with <span class="sc">matlab</span> and others are provided because they are
useful.

<!-- ./time/clock.m -->
   <p><a name="doc_002dclock"></a>

<div class="defun">
&mdash; Function File:  <b>clock</b> ()<var><a name="index-clock-2277"></a></var><br>
<blockquote><p>Return a vector containing the current year, month (1-12), day (1-31),
hour (0-23), minute (0-59) and second (0-61).  For example,

     <pre class="example">          clock ()
               &rArr; [ 1993, 8, 20, 4, 56, 1 ]
</pre>
        <p>The function clock is more accurate on systems that have the
<code>gettimeofday</code> function. 
</p></blockquote></div>

<!-- ./time/date.m -->
   <p><a name="doc_002ddate"></a>

<div class="defun">
&mdash; Function File:  <b>date</b> ()<var><a name="index-date-2278"></a></var><br>
<blockquote><p>Return the date as a character string in the form DD-MMM-YY.  For
example,

     <pre class="example">          date ()
               &rArr; "20-Aug-93"
</pre>
        </blockquote></div>

<!-- ./time/etime.m -->
   <p><a name="doc_002detime"></a>

<div class="defun">
&mdash; Function File:  <b>etime</b> (<var>t1, t2</var>)<var><a name="index-etime-2279"></a></var><br>
<blockquote><p>Return the difference (in seconds) between two time values returned from
<code>clock</code>.  For example:

     <pre class="example">          t0 = clock ();
           many computations later...
          elapsed_time = etime (clock (), t0);
</pre>
        <p class="noindent">will set the variable <code>elapsed_time</code> to the number of seconds since
the variable <code>t0</code> was set. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dtic.html#doc_002dtic">tic</a>, <a href="doc_002dtoc.html#doc_002dtoc">toc</a>, <a href="doc_002dclock.html#doc_002dclock">clock</a>, <a href="doc_002dcputime.html#doc_002dcputime">cputime</a>. 
</p></blockquote></div>

<!-- data.cc -->
   <p><a name="doc_002dcputime"></a>

<div class="defun">
&mdash; Built-in Function: [<var>total</var>, <var>user</var>, <var>system</var>] = <b>cputime</b> ()<var>;<a name="index-cputime-2280"></a></var><br>
<blockquote><p>Return the CPU time used by your Octave session.  The first output is
the total time spent executing your process and is equal to the sum of
second and third outputs, which are the number of CPU seconds spent
executing in user mode and the number of CPU seconds spent executing in
system mode, respectively.  If your system does not have a way to report
CPU time usage, <code>cputime</code> returns 0 for each of its output values. 
Note that because Octave used some CPU time to start, it is reasonable
to check to see if <code>cputime</code> works by checking to see if the total
CPU time used is nonzero. 
</p></blockquote></div>

<!-- ./time/is_leap_year.m -->
   <p><a name="doc_002dis_005fleap_005fyear"></a>

<div class="defun">
&mdash; Function File:  <b>is_leap_year</b> (<var>year</var>)<var><a name="index-is_005fleap_005fyear-2281"></a></var><br>
<blockquote><p>Return 1 if the given year is a leap year and 0 otherwise.  If no
arguments are provided, <code>is_leap_year</code> will use the current year. 
For example,

     <pre class="example">          is_leap_year (2000)
               &rArr; 1
</pre>
        </blockquote></div>

   <p><a name="doc_002dtoc"></a><!-- data.cc -->
<a name="doc_002dtic"></a>

<div class="defun">
&mdash; Built-in Function:  <b>tic</b> ()<var><a name="index-tic-2282"></a></var><br>
&mdash; Built-in Function:  <b>toc</b> ()<var><a name="index-toc-2283"></a></var><br>
<blockquote><p>Set or check a wall-clock timer.  Calling <code>tic</code> without an
output argument sets the timer.  Subsequent calls to <code>toc</code>
return the number of seconds since the timer was set.  For example,

     <pre class="example">          tic ();
          # many computations later...
          elapsed_time = toc ();
</pre>
        <p class="noindent">will set the variable <code>elapsed_time</code> to the number of seconds since
the most recent call to the function <code>tic</code>.

        <p>If called with one output argument then this function returns a scalar
of type <code>uint64</code> and the wall-clock timer is not started.

     <pre class="example">          t = tic; sleep (5); (double (tic ()) - double (t)) * 1e-6
               &rArr; 5
</pre>
        <p>Nested timing with <code>tic</code> and <code>toc</code> is not supported. 
Therefore <code>toc</code> will always return the elapsed time from the most
recent call to <code>tic</code>.

        <p>If you are more interested in the CPU time that your process used, you
should use the <code>cputime</code> function instead.  The <code>tic</code> and
<code>toc</code> functions report the actual wall clock time that elapsed
between the calls.  This may include time spent processing other jobs or
doing nothing at all.  For example,

     <pre class="example">          tic (); sleep (5); toc ()
               &rArr; 5
          t = cputime (); sleep (5); cputime () - t
               &rArr; 0
</pre>
        <p class="noindent">(This example also illustrates that the CPU timer may have a fairly
coarse resolution.) 
</p></blockquote></div>

<!-- sysdep.cc -->
   <p><a name="doc_002dpause"></a>

<div class="defun">
&mdash; Built-in Function:  <b>pause</b> (<var>seconds</var>)<var><a name="index-pause-2284"></a></var><br>
<blockquote><p>Suspend the execution of the program.  If invoked without any arguments,
Octave waits until you type a character.  With a numeric argument, it
pauses for the given number of seconds.  For example, the following
statement prints a message and then waits 5 seconds before clearing the
screen.

     <pre class="example">          fprintf (stderr, "wait please...\n");
          pause (5);
          clc;
</pre>
        </blockquote></div>

<!-- sysdep.cc -->
   <p><a name="doc_002dsleep"></a>

<div class="defun">
&mdash; Built-in Function:  <b>sleep</b> (<var>seconds</var>)<var><a name="index-sleep-2285"></a></var><br>
<blockquote><p>Suspend the execution of the program for the given number of seconds. 
</p></blockquote></div>

<!-- sysdep.cc -->
   <p><a name="doc_002dusleep"></a>

<div class="defun">
&mdash; Built-in Function:  <b>usleep</b> (<var>microseconds</var>)<var><a name="index-usleep-2286"></a></var><br>
<blockquote><p>Suspend the execution of the program for the given number of
microseconds.  On systems where it is not possible to sleep for periods
of time less than one second, <code>usleep</code> will pause the execution for
<code>round (</code><var>microseconds</var><code> / 1e6)</code> seconds. 
</p></blockquote></div>

<!-- ./time/datenum.m -->
   <p><a name="doc_002ddatenum"></a>

<div class="defun">
&mdash; Function File:  <b>datenum</b> (<var>year, month, day</var>)<var><a name="index-datenum-2287"></a></var><br>
&mdash; Function File:  <b>datenum</b> (<var>year, month, day, hour</var>)<var><a name="index-datenum-2288"></a></var><br>
&mdash; Function File:  <b>datenum</b> (<var>year, month, day, hour, minute</var>)<var><a name="index-datenum-2289"></a></var><br>
&mdash; Function File:  <b>datenum</b> (<var>year, month, day, hour, minute, second</var>)<var><a name="index-datenum-2290"></a></var><br>
&mdash; Function File:  <b>datenum</b> (<code>"date"</code>)<var><a name="index-datenum-2291"></a></var><br>
&mdash; Function File:  <b>datenum</b> (<code>"date"</code><var>, p</var>)<var><a name="index-datenum-2292"></a></var><br>
<blockquote><p>Returns the specified local time as a day number, with Jan 1, 0000
being day 1.  By this reckoning, Jan 1, 1970 is day number 719529. 
The fractional portion, <var>p</var>, corresponds to the portion of the
specified day.

        <p>Notes:

          <ul>
<li>Years can be negative and/or fractional. 
<li>Months below 1 are considered to be January. 
<li>Days of the month start at 1. 
<li>Days beyond the end of the month go into subsequent months. 
<li>Days before the beginning of the month go to the previous month. 
<li>Days can be fractional. 
</ul>

        <p><strong>Warning:</strong> this function does not attempt to handle Julian
calendars so dates before Octave 15, 1582 are wrong by as much
as eleven days.  Also be aware that only Roman Catholic countries
adopted the calendar in 1582.  It took until 1924 for it to be
adopted everywhere.  See the Wikipedia entry on the Gregorian
calendar for more details.

        <p><strong>Warning:</strong> leap seconds are ignored.  A table of leap seconds
is available on the Wikipedia entry for leap seconds. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002ddate.html#doc_002ddate">date</a>, <a href="doc_002dclock.html#doc_002dclock">clock</a>, <a href="doc_002dnow.html#doc_002dnow">now</a>, <a href="doc_002ddatestr.html#doc_002ddatestr">datestr</a>, <a href="doc_002ddatevec.html#doc_002ddatevec">datevec</a>, <a href="doc_002dcalendar.html#doc_002dcalendar">calendar</a>, <a href="doc_002dweekday.html#doc_002dweekday">weekday</a>. 
</p></blockquote></div>

<!-- ./time/datestr.m -->
   <p><a name="doc_002ddatestr"></a>

<div class="defun">
&mdash; Function File: <var>str</var> = <b>datestr</b> (<var>date, </var>[<var>f, </var>[<var>p</var>]])<var><a name="index-datestr-2293"></a></var><br>
<blockquote><p>Format the given date/time according to the format <code>f</code> and return
the result in <var>str</var>.  <var>date</var> is a serial date number (see
<code>datenum</code>) or a date vector (see <code>datevec</code>).  The value of
<var>date</var> may also be a string or cell array of strings.

        <p><var>f</var> can be an integer which corresponds to one of the codes in
the table below, or a date format string.

        <p><var>p</var> is the year at the start of the century in which two-digit years
are to be interpreted in.  If not specified, it defaults to the current
year minus 50.

        <p>For example, the date 730736.65149 (2000-09-07 15:38:09.0934) would be
formatted as follows:

        <p><table summary=""><tr align="left"><th valign="top" width="10%">Code </th><th valign="top" width="45%">Format </th><th valign="top" width="35%">Example
<br></th></tr><tr align="left"><td valign="top" width="10%">0 </td><td valign="top" width="45%">dd-mmm-yyyy HH:MM:SS   </td><td valign="top" width="35%">07-Sep-2000 15:38:09
<br></td></tr><tr align="left"><td valign="top" width="10%">1 </td><td valign="top" width="45%">dd-mmm-yyyy            </td><td valign="top" width="35%">07-Sep-2000
<br></td></tr><tr align="left"><td valign="top" width="10%">2 </td><td valign="top" width="45%">mm/dd/yy               </td><td valign="top" width="35%">09/07/00
<br></td></tr><tr align="left"><td valign="top" width="10%">3 </td><td valign="top" width="45%">mmm                    </td><td valign="top" width="35%">Sep
<br></td></tr><tr align="left"><td valign="top" width="10%">4 </td><td valign="top" width="45%">m                      </td><td valign="top" width="35%">S
<br></td></tr><tr align="left"><td valign="top" width="10%">5 </td><td valign="top" width="45%">mm                     </td><td valign="top" width="35%">09
<br></td></tr><tr align="left"><td valign="top" width="10%">6 </td><td valign="top" width="45%">mm/dd                  </td><td valign="top" width="35%">09/07
<br></td></tr><tr align="left"><td valign="top" width="10%">7 </td><td valign="top" width="45%">dd                     </td><td valign="top" width="35%">07
<br></td></tr><tr align="left"><td valign="top" width="10%">8 </td><td valign="top" width="45%">ddd                    </td><td valign="top" width="35%">Thu
<br></td></tr><tr align="left"><td valign="top" width="10%">9 </td><td valign="top" width="45%">d                      </td><td valign="top" width="35%">T
<br></td></tr><tr align="left"><td valign="top" width="10%">10 </td><td valign="top" width="45%">yyyy                   </td><td valign="top" width="35%">2000
<br></td></tr><tr align="left"><td valign="top" width="10%">11 </td><td valign="top" width="45%">yy                     </td><td valign="top" width="35%">00
<br></td></tr><tr align="left"><td valign="top" width="10%">12 </td><td valign="top" width="45%">mmmyy                  </td><td valign="top" width="35%">Sep00
<br></td></tr><tr align="left"><td valign="top" width="10%">13 </td><td valign="top" width="45%">HH:MM:SS               </td><td valign="top" width="35%">15:38:09
<br></td></tr><tr align="left"><td valign="top" width="10%">14 </td><td valign="top" width="45%">HH:MM:SS PM            </td><td valign="top" width="35%">03:38:09 PM
<br></td></tr><tr align="left"><td valign="top" width="10%">15 </td><td valign="top" width="45%">HH:MM                  </td><td valign="top" width="35%">15:38
<br></td></tr><tr align="left"><td valign="top" width="10%">16 </td><td valign="top" width="45%">HH:MM PM               </td><td valign="top" width="35%">03:38 PM
<br></td></tr><tr align="left"><td valign="top" width="10%">17 </td><td valign="top" width="45%">QQ-YY                  </td><td valign="top" width="35%">Q3-00
<br></td></tr><tr align="left"><td valign="top" width="10%">18 </td><td valign="top" width="45%">QQ                     </td><td valign="top" width="35%">Q3
<br></td></tr><tr align="left"><td valign="top" width="10%">19 </td><td valign="top" width="45%">dd/mm                  </td><td valign="top" width="35%">13/03
<br></td></tr><tr align="left"><td valign="top" width="10%">20 </td><td valign="top" width="45%">dd/mm/yy               </td><td valign="top" width="35%">13/03/95
<br></td></tr><tr align="left"><td valign="top" width="10%">21 </td><td valign="top" width="45%">mmm.dd.yyyy HH:MM:SS   </td><td valign="top" width="35%">Mar.03.1962 13:53:06
<br></td></tr><tr align="left"><td valign="top" width="10%">22 </td><td valign="top" width="45%">mmm.dd.yyyy            </td><td valign="top" width="35%">Mar.03.1962
<br></td></tr><tr align="left"><td valign="top" width="10%">23 </td><td valign="top" width="45%">mm/dd/yyyy             </td><td valign="top" width="35%">03/13/1962
<br></td></tr><tr align="left"><td valign="top" width="10%">24 </td><td valign="top" width="45%">dd/mm/yyyy             </td><td valign="top" width="35%">12/03/1962
<br></td></tr><tr align="left"><td valign="top" width="10%">25 </td><td valign="top" width="45%">yy/mm/dd               </td><td valign="top" width="35%">95/03/13
<br></td></tr><tr align="left"><td valign="top" width="10%">26 </td><td valign="top" width="45%">yyyy/mm/dd             </td><td valign="top" width="35%">1995/03/13
<br></td></tr><tr align="left"><td valign="top" width="10%">27 </td><td valign="top" width="45%">QQ-YYYY                </td><td valign="top" width="35%">Q4-2132
<br></td></tr><tr align="left"><td valign="top" width="10%">28 </td><td valign="top" width="45%">mmmyyyy                </td><td valign="top" width="35%">Mar2047
<br></td></tr><tr align="left"><td valign="top" width="10%">29 </td><td valign="top" width="45%">yyyymmdd               </td><td valign="top" width="35%">20470313
<br></td></tr><tr align="left"><td valign="top" width="10%">30 </td><td valign="top" width="45%">yyyymmddTHHMMSS        </td><td valign="top" width="35%">20470313T132603
<br></td></tr><tr align="left"><td valign="top" width="10%">31 </td><td valign="top" width="45%">yyyy-mm-dd HH:MM:SS    </td><td valign="top" width="35%">1047-03-13 13:26:03
        <br></td></tr></table>

        <p>If <var>f</var> is a format string, the following symbols are recognized:

        <p><table summary=""><tr align="left"><th valign="top" width="10%">Symbol </th><th valign="top" width="70%">Meaning </th><th valign="top" width="20%">Example
<br></th></tr><tr align="left"><td valign="top" width="10%">yyyy </td><td valign="top" width="70%">Full year                                    </td><td valign="top" width="20%">2005
<br></td></tr><tr align="left"><td valign="top" width="10%">yy   </td><td valign="top" width="70%">Two-digit year                               </td><td valign="top" width="20%">2005
<br></td></tr><tr align="left"><td valign="top" width="10%">mmmm </td><td valign="top" width="70%">Full month name                              </td><td valign="top" width="20%">December
<br></td></tr><tr align="left"><td valign="top" width="10%">mmm  </td><td valign="top" width="70%">Abbreviated month name                       </td><td valign="top" width="20%">Dec
<br></td></tr><tr align="left"><td valign="top" width="10%">mm   </td><td valign="top" width="70%">Numeric month number (padded with zeros)     </td><td valign="top" width="20%">01, 08, 12
<br></td></tr><tr align="left"><td valign="top" width="10%">m    </td><td valign="top" width="70%">First letter of month name (capitalized)     </td><td valign="top" width="20%">D
<br></td></tr><tr align="left"><td valign="top" width="10%">dddd </td><td valign="top" width="70%">Full weekday name                            </td><td valign="top" width="20%">Sunday
<br></td></tr><tr align="left"><td valign="top" width="10%">ddd  </td><td valign="top" width="70%">Abbreviated weekday name                     </td><td valign="top" width="20%">Sun
<br></td></tr><tr align="left"><td valign="top" width="10%">dd   </td><td valign="top" width="70%">Numeric day of month (padded with zeros)     </td><td valign="top" width="20%">11
<br></td></tr><tr align="left"><td valign="top" width="10%">d    </td><td valign="top" width="70%">First letter of weekday name (capitalized)   </td><td valign="top" width="20%">S
<br></td></tr><tr align="left"><td valign="top" width="10%">HH   </td><td valign="top" width="70%">Hour of day, padded with zeros if PM is set  </td><td valign="top" width="20%">09:00
<br></td></tr><tr align="left"><td valign="top" width="10%"></td><td valign="top" width="70%">and not padded with zeros otherwise          </td><td valign="top" width="20%">9:00 AM
<br></td></tr><tr align="left"><td valign="top" width="10%">MM   </td><td valign="top" width="70%">Minute of hour (padded with zeros)           </td><td valign="top" width="20%">10:05
<br></td></tr><tr align="left"><td valign="top" width="10%">SS   </td><td valign="top" width="70%">Second of minute (padded with zeros)         </td><td valign="top" width="20%">10:05:03
<br></td></tr><tr align="left"><td valign="top" width="10%">PM   </td><td valign="top" width="70%">Use 12-hour time format                      </td><td valign="top" width="20%">11:30 PM
        <br></td></tr></table>

        <p>If <var>f</var> is not specified or is <code>-1</code>, then use 0, 1 or 16,
depending on whether the date portion or the time portion of
<var>date</var> is empty.

        <p>If <var>p</var> is nor specified, it defaults to the current year minus 50.

        <p>If a matrix or cell array of dates is given, a vector of date strings is
returned.

     <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002ddatenum.html#doc_002ddatenum">datenum</a>, <a href="doc_002ddatevec.html#doc_002ddatevec">datevec</a>, <a href="doc_002ddate.html#doc_002ddate">date</a>, <a href="doc_002dclock.html#doc_002dclock">clock</a>, <a href="doc_002dnow.html#doc_002dnow">now</a>, <a href="doc_002ddatetick.html#doc_002ddatetick">datetick</a>. 
</p></blockquote></div>

<!-- ./time/datevec.m -->
   <p><a name="doc_002ddatevec"></a>

<div class="defun">
&mdash; Function File: <var>v</var> = <b>datevec</b> (<var>date</var>)<var><a name="index-datevec-2294"></a></var><br>
&mdash; Function File: <var>v</var> = <b>datevec</b> (<var>date, f</var>)<var><a name="index-datevec-2295"></a></var><br>
&mdash; Function File: <var>v</var> = <b>datevec</b> (<var>date, p</var>)<var><a name="index-datevec-2296"></a></var><br>
&mdash; Function File: <var>v</var> = <b>datevec</b> (<var>date, f, p</var>)<var><a name="index-datevec-2297"></a></var><br>
&mdash; Function File: [<var>y</var>, <var>m</var>, <var>d</var>, <var>h</var>, <var>mi</var>, <var>s</var>] = <b>datevec</b> (<var><small class="dots">...</small></var>)<var><a name="index-datevec-2298"></a></var><br>
<blockquote><p>Convert a serial date number (see <code>datenum</code>) or date string (see
<code>datestr</code>) into a date vector.

        <p>A date vector is a row vector with six members, representing the year,
month, day, hour, minute, and seconds respectively.

        <p><var>f</var> is the format string used to interpret date strings
(see <code>datestr</code>).

        <p><var>p</var> is the year at the start of the century in which two-digit years
are to be interpreted in.  If not specified, it defaults to the current
year minus 50. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002ddatenum.html#doc_002ddatenum">datenum</a>, <a href="doc_002ddatestr.html#doc_002ddatestr">datestr</a>, <a href="doc_002ddate.html#doc_002ddate">date</a>, <a href="doc_002dclock.html#doc_002dclock">clock</a>, <a href="doc_002dnow.html#doc_002dnow">now</a>. 
</p></blockquote></div>

<!-- ./time/addtodate.m -->
   <p><a name="doc_002daddtodate"></a>

<div class="defun">
&mdash; Function File: <var>d</var> = <b>addtodate</b> (<var>d, q, f</var>)<var><a name="index-addtodate-2299"></a></var><br>
<blockquote><p>Add <var>q</var> amount of time (with units <var>f</var>) to the datenum, <var>d</var>.

        <p><var>f</var> must be one of "year", "month", "day", "hour", "minute", or
"second". 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002ddatenum.html#doc_002ddatenum">datenum</a>, <a href="doc_002ddatevec.html#doc_002ddatevec">datevec</a>. 
</p></blockquote></div>

<!-- ./time/calendar.m -->
   <p><a name="doc_002dcalendar"></a>

<div class="defun">
&mdash; Function File:  <b>calendar</b> (<var><small class="dots">...</small></var>)<var><a name="index-calendar-2300"></a></var><br>
&mdash; Function File: <var>c</var> = <b>calendar</b> ()<var><a name="index-calendar-2301"></a></var><br>
&mdash; Function File: <var>c</var> = <b>calendar</b> (<var>d</var>)<var><a name="index-calendar-2302"></a></var><br>
&mdash; Function File: <var>c</var> = <b>calendar</b> (<var>y, m</var>)<var><a name="index-calendar-2303"></a></var><br>
<blockquote><p>If called with no arguments, return the current monthly calendar in
a 6x7 matrix.

        <p>If <var>d</var> is specified, return the calendar for the month containing
the day <var>d</var>, which must be a serial date number or a date string.

        <p>If <var>y</var> and <var>m</var> are specified, return the calendar for year <var>y</var>
and month <var>m</var>.

        <p>If no output arguments are specified, print the calendar on the screen
instead of returning a matrix. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002ddatenum.html#doc_002ddatenum">datenum</a>. 
</p></blockquote></div>

<!-- ./time/weekday.m -->
   <p><a name="doc_002dweekday"></a>

<div class="defun">
&mdash; Function File: [<var>n</var>, <var>s</var>] = <b>weekday</b> (<var>d, </var>[<var>form</var>])<var><a name="index-weekday-2304"></a></var><br>
<blockquote><p>Return the day of week as a number in <var>n</var> and a string in <var>s</var>,
for example <code>[1, "Sun"]</code>, <code>[2, "Mon"]</code>, <small class="dots">...</small>, or
<code>[7, "Sat"]</code>.

        <p><var>d</var> is a serial date number or a date string.

        <p>If the string <var>form</var> is given and is <code>"long"</code>, <var>s</var> will
contain the full name of the weekday; otherwise (or if <var>form</var> is
<code>"short"</code>), <var>s</var> will contain the abbreviated name of the weekday. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002ddatenum.html#doc_002ddatenum">datenum</a>, <a href="doc_002ddatevec.html#doc_002ddatevec">datevec</a>, <a href="doc_002deomday.html#doc_002deomday">eomday</a>. 
</p></blockquote></div>

<!-- ./time/eomday.m -->
   <p><a name="doc_002deomday"></a>

<div class="defun">
&mdash; Function File: <var>e</var> = <b>eomday</b> (<var>y, m</var>)<var><a name="index-eomday-2305"></a></var><br>
<blockquote><p>Return the last day of the month <var>m</var> for the year <var>y</var>. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002ddatenum.html#doc_002ddatenum">datenum</a>, <a href="doc_002ddatevec.html#doc_002ddatevec">datevec</a>, <a href="doc_002dweekday.html#doc_002dweekday">weekday</a>. 
</p></blockquote></div>

<!-- ./time/datetick.m -->
   <p><a name="doc_002ddatetick"></a>

<div class="defun">
&mdash; Function File:  <b>datetick</b> (<var>form</var>)<var><a name="index-datetick-2306"></a></var><br>
&mdash; Function File:  <b>datetick</b> (<var>axis, form</var>)<var><a name="index-datetick-2307"></a></var><br>
&mdash; Function File:  <b>datetick</b> (<var><small class="dots">...</small>, "keeplimits"</var>)<var><a name="index-datetick-2308"></a></var><br>
&mdash; Function File:  <b>datetick</b> (<var><small class="dots">...</small>, "keepticks"</var>)<var><a name="index-datetick-2309"></a></var><br>
&mdash; Function File:  <b>datetick</b> (<var><small class="dots">...</small>ax, <small class="dots">...</small></var>)<var><a name="index-datetick-2310"></a></var><br>
<blockquote><p>Adds date formatted tick labels to an axis.  The axis the apply the
ticks to is determined by <var>axis</var> that can take the values "x",
"y" or "z".  The default value is "x".  The formatting of the labels is
determined by the variable <var>form</var>, that can either be a string in
the format needed by <code>dateform</code>, or a positive integer that can
be accepted by <code>datestr</code>. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002ddatenum.html#doc_002ddatenum">datenum</a>, <a href="doc_002ddatestr.html#doc_002ddatestr">datestr</a>. 
</p></blockquote></div>

   </body></html>