stopwatch.html
来自「perl教程」· HTML 代码 · 共 121 行
HTML
121 行
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../displayToc.js"></script>
<script language="JavaScript" src="../../tocParas.js"></script>
<script language="JavaScript" src="../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../scineplex.css">
<title>ActiveState::StopWatch - Time code</title>
<link rel="stylesheet" href="../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>
<body>
<script>writelinks('__top__',2);</script>
<h1><a>ActiveState::StopWatch - Time code</a></h1>
<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<li><a href="#copyright">COPYRIGHT</a></li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>ActiveState::StopWatch - Time code</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
<span class="keyword">use</span> <span class="variable">ActiveState::StopWatch</span> <span class="string">qw(start_watch stop_watch read_watch real_time)</span><span class="operator">;</span>
</pre>
<pre>
<span class="keyword">my</span> <span class="variable">$w</span> <span class="operator">=</span> <span class="variable">start_watch</span><span class="operator">();</span>
<span class="comment"># ... do stuff ...</span>
<span class="keyword">print</span> <span class="variable">read_watch</span><span class="operator">(</span><span class="variable">$w</span><span class="operator">);</span>
<span class="comment"># ... do stuff ...</span>
<span class="keyword">print</span> <span class="variable">stop_watch</span><span class="operator">(</span><span class="variable">$w</span><span class="operator">);</span>
</pre>
<pre>
<span class="comment"># restart it</span>
<span class="variable">start_watch</span><span class="operator">(</span><span class="variable">$w</span><span class="operator">);</span>
<span class="keyword">print</span> <span class="variable">stop_watch</span><span class="operator">(</span><span class="variable">$w</span><span class="operator">);</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>The ActiveState::StopWatch module provide functions that can be used
to measure the time spent by sections of code. The following
functions are provided:</p>
<dl>
<dt><strong><a name="item_start_watch">$w = <code>start_watch()</code></a></strong>
<dt><strong>start_watch( $w )</strong>
<dd>
<p>Without argument this function creates a new watch object. With
argument it can restart a watch that has been stopped after invoking
the <a href="#item_stop_watch"><code>stop_watch()</code></a> function on it. If the watch provided is not stopped
then its state is not affected.</p>
</dd>
</li>
<dt><strong><a name="item_read_watch">$str = read_watch( $w )</a></strong>
<dd>
<p>This function returns a string that tells how much real, user and
system time has ticked during the time the watch has been running.
The string will look like this:</p>
</dd>
<dd>
<pre>
r=12.5s u=4.90s s=0.55s cu=1.22s cs=0.22s</pre>
</dd>
<dd>
<p>The 'cu' and 'cs' field gives time spent in children of the current
process during the time the watch has been running. The child fields
are not shown if they are 0.</p>
</dd>
</li>
<dt><strong><a name="item_stop_watch">$str = stop_watch( $w )</a></strong>
<dd>
<p>This function return a string of the same format as for read_watch(),
but it will also stop the clock from running. This means that
<a href="#item_read_watch"><code>read_watch()</code></a> will continue to return the same result. The watch can
be restarted by calling <a href="#item_start_watch"><code>start_watch()</code></a> with the watch object as
argument.</p>
</dd>
</li>
<dt><strong><a name="item_real_time">$r = real_time( $w )</a></strong>
<dd>
<p>This function returns the number of seconds of real time passed during
the time the watch has been running.</p>
</dd>
</li>
</dl>
<p>Only the <a href="#item_start_watch"><code>start_watch()</code></a> and <a href="#item_stop_watch"><code>stop_watch()</code></a> functions are exported by default.</p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright (C) 2003 ActiveState Corp. All rights reserved.</p>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?