Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / html / python / lib / node442.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="prev" href="node441.html" />
<link rel="parent" href="module-resource.html" />
<link rel="next" href="module-nis.html" />
<meta name='aesop' content='information' />
<title>8.14.2 Resource Usage</title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="8.14.1 Resource Limits"
href="node441.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="8.14 resource "
href="module-resource.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="8.15 nis "
href="module-nis.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="node441.html">8.14.1 Resource Limits</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-resource.html">8.14 resource </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-nis.html">8.15 nis </A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION00101420000000000000000">
8.14.2 Resource Usage</A>
</H2>
<P>
These functions are used to retrieve resource usage information:
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-3071' xml:id='l2h-3071' class="function">getrusage</tt></b>(</nobr></td>
<td><var>who</var>)</td></tr></table></dt>
<dd>
This function returns an object that describes the resources
consumed by either the current process or its children, as specified
by the <var>who</var> parameter. The <var>who</var> parameter should be
specified using one of the <tt class="constant">RUSAGE_*</tt> constants described
below.
<P>
The fields of the return value each describe how a particular system
resource has been used, e.g. amount of time spent running is user mode
or number of times the process was swapped out of main memory. Some
values are dependent on the clock tick internal, e.g. the amount of
memory the process is using.
<P>
For backward compatibility, the return value is also accessible as
a tuple of 16 elements.
<P>
The fields <tt class="member">ru_utime</tt> and <tt class="member">ru_stime</tt> of the return value
are floating point values representing the amount of time spent
executing in user mode and the amount of time spent executing in system
mode, respectively. The remaining values are integers. Consult the
<span class="manpage"><i>getrusage</i>(2)</span> man page for detailed information about these
values. A brief summary is presented here:
<P>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="right" >Index</th>
<th class="left" >Field</th>
<th class="left" >Resource</th>
</tr>
</thead>
<tbody>
<tr><td class="right" valign="baseline"><code>0</code></td>
<td class="left" ><tt class="member">ru_utime</tt></td>
<td class="left" >time in user mode (float)</td></tr>
<tr><td class="right" valign="baseline"><code>1</code></td>
<td class="left" ><tt class="member">ru_stime</tt></td>
<td class="left" >time in system mode (float)</td></tr>
<tr><td class="right" valign="baseline"><code>2</code></td>
<td class="left" ><tt class="member">ru_maxrss</tt></td>
<td class="left" >maximum resident set size</td></tr>
<tr><td class="right" valign="baseline"><code>3</code></td>
<td class="left" ><tt class="member">ru_ixrss</tt></td>
<td class="left" >shared memory size</td></tr>
<tr><td class="right" valign="baseline"><code>4</code></td>
<td class="left" ><tt class="member">ru_idrss</tt></td>
<td class="left" >unshared memory size</td></tr>
<tr><td class="right" valign="baseline"><code>5</code></td>
<td class="left" ><tt class="member">ru_isrss</tt></td>
<td class="left" >unshared stack size</td></tr>
<tr><td class="right" valign="baseline"><code>6</code></td>
<td class="left" ><tt class="member">ru_minflt</tt></td>
<td class="left" >page faults not requiring I/O</td></tr>
<tr><td class="right" valign="baseline"><code>7</code></td>
<td class="left" ><tt class="member">ru_majflt</tt></td>
<td class="left" >page faults requiring I/O</td></tr>
<tr><td class="right" valign="baseline"><code>8</code></td>
<td class="left" ><tt class="member">ru_nswap</tt></td>
<td class="left" >number of swap outs</td></tr>
<tr><td class="right" valign="baseline"><code>9</code></td>
<td class="left" ><tt class="member">ru_inblock</tt></td>
<td class="left" >block input operations</td></tr>
<tr><td class="right" valign="baseline"><code>10</code></td>
<td class="left" ><tt class="member">ru_oublock</tt></td>
<td class="left" >block output operations</td></tr>
<tr><td class="right" valign="baseline"><code>11</code></td>
<td class="left" ><tt class="member">ru_msgsnd</tt></td>
<td class="left" >messages sent</td></tr>
<tr><td class="right" valign="baseline"><code>12</code></td>
<td class="left" ><tt class="member">ru_msgrcv</tt></td>
<td class="left" >messages received</td></tr>
<tr><td class="right" valign="baseline"><code>13</code></td>
<td class="left" ><tt class="member">ru_nsignals</tt></td>
<td class="left" >signals received</td></tr>
<tr><td class="right" valign="baseline"><code>14</code></td>
<td class="left" ><tt class="member">ru_nvcsw</tt></td>
<td class="left" >voluntary context switches</td></tr>
<tr><td class="right" valign="baseline"><code>15</code></td>
<td class="left" ><tt class="member">ru_nivcsw</tt></td>
<td class="left" >involuntary context switches</td></tr></tbody>
</table></div>
<P>
This function will raise a <tt class="exception">ValueError</tt> if an invalid
<var>who</var> parameter is specified. It may also raise
<tt class="exception">error</tt> exception in unusual circumstances.
<P>
<span class="versionnote">Changed in version 2.3:
Added access to values as attributes of the
returned object.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-3072' xml:id='l2h-3072' class="function">getpagesize</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns the number of bytes in a system page. (This need not be the
same as the hardware page size.) This function is useful for
determining the number of bytes of memory a process is using. The
third element of the tuple returned by <tt class="function">getrusage()</tt> describes
memory usage in pages; multiplying by page size produces number of
bytes.
</dl>
<P>
The following <tt class="constant">RUSAGE_*</tt> symbols are passed to the
<tt class="function">getrusage()</tt> function to specify which processes information
should be provided for.
<P>
<dl><dt><b><tt id='l2h-3073' xml:id='l2h-3073'>RUSAGE_SELF</tt></b></dt>
<dd>
<tt class="constant">RUSAGE_SELF</tt> should be used to
request information pertaining only to the process itself.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-3074' xml:id='l2h-3074'>RUSAGE_CHILDREN</tt></b></dt>
<dd>
Pass to <tt class="function">getrusage()</tt> to request resource information for
child processes of the calling process.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-3075' xml:id='l2h-3075'>RUSAGE_BOTH</tt></b></dt>
<dd>
Pass to <tt class="function">getrusage()</tt> to request resources consumed by both
the current process and child processes. May not be available on all
systems.
</dd></dl>
<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="8.14.1 Resource Limits"
href="node441.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="8.14 resource "
href="module-resource.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="8.15 nis "
href="module-nis.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="node441.html">8.14.1 Resource Limits</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-resource.html">8.14 resource </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-nis.html">8.15 nis </A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>