Location: PHPKode > scripts > Script timer > script-timer/Documentation/script_timer.html
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<!-- template designed by Marco Von Ballmoos -->
			<title>Docs For Class script_timer</title>
<style type="text/css">
a { color: #0000FF; text-decoration: none; }
a:hover { color: #FF0000; text-decoration: underline; }
a:active { color: #FF0000; text-decoration: underline; }

body { background-color: #EEEEEE; font-family: Verdana, Arial, sans-serif }
body, table { font-size: 10pt }
a img { border: 0px; }
dd { margin-left: 0px; padding-left: 1em; }

/* Page layout/boxes */

.info-box {}
.info-box-title { margin: 1em 0em 0em 0em; padding: .25em; font-weight: normal; font-size: 14pt; border: 2px solid #999999; background-color: #DDDDDD }
.info-box-body { border: 1px solid #999999; padding: .5em; background-color: #F8F8F8; }
.nav-bar { font-size: 8pt; white-space: nowrap; text-align: right; padding: .2em; margin: 0em 0em 1em 0em; }

.oddrow { background-color: #DDDDDD; border: 1px solid #999999; padding: .5em; margin-bottom: 1em}
.evenrow { background-color: #DDDDDD; border: 1px solid #999999; padding: .5em; margin-bottom: 1em}

.page-body { max-width: 800px; margin: auto; }
.tree dl { margin: 0px }

/* Index formatting classes */

.index-item-body { margin-top: .5em; margin-bottom: .5em}
.index-item-description { margin-top: .25em }
.index-item-details { font-weight: normal; font-style: italic; font-size: 8pt }
.index-letter-section { background-color: #EEEEEE; border: 1px dotted #999999; padding: .5em; margin-bottom: 1em}
.index-letter-title { font-size: 12pt; font-weight: bold }
.index-letter-menu { text-align: center; margin: 1em }
.index-letter { font-size: 12pt }

/* Docbook classes */

.description {}
.short-description { font-weight: bold; color: #666666; }
.tags {	padding-left: 0em; margin-left: 3em; color: #666666; list-style-type: square; }
.parameters {	padding-left: 0em; margin-left: 3em; font-style: italic; list-style-type: square; }
.redefinitions { font-size: 8pt; padding-left: 0em; margin-left: 2em; }
.package {  }
.package-title { font-weight: bold; font-size: 14pt; border-bottom: 1px solid black }
.package-details { font-size: 85%; }
.sub-package { font-weight: bold; font-size: 120% }
.tutorial { border-width: thin; border-color: #0066ff }
.tutorial-nav-box { width: 100%; border: 2px solid #999999; background-color: #DDDDDD }
.nav-button-disabled { color: #999999; }
.nav-button:active,
.nav-button:focus,
.nav-button:hover { background-color: #AAAAAA; outline: 1px solid #666666; text-decoration: none }
.folder-title { font-style: italic }

/* Generic formatting */

.field { font-weight: bold; }
.detail { font-size: 8pt; }
.notes { font-style: italic; font-size: 8pt; }
.separator { background-color: #999999; height: 2px; }
.warning {  color: #FF6600; }
.disabled { font-style: italic; color: #999999; }

/* Code elements */

.line-number {  }

.class-table { width: 100%; }
.class-table-header { border-bottom: 1px dotted #666666; text-align: left}
.class-name { color: #000000; font-weight: bold; }

.method-summary { padding-left: 1em; font-size: 8pt }
.method-header { }
.method-definition { margin-bottom: .3em }
.method-title { font-weight: bold; }
.method-name { font-weight: bold; }
.method-signature { font-size: 85%; color: #0066BB; margin: .5em 0em }
.method-result { font-style: italic; }

.var-summary { padding-left: 1em; font-size: 8pt; }
.var-header { }
.var-title { margin-bottom: .3em }
.var-type { color: red; font-weight: bold }
.var-name { font-weight: bold; }
.var-default {}
.var-description { font-weight: normal; color: #000000; }

.include-title {  }
.include-type { font-style: italic; }
.include-name { font-weight: bold; }

.const-title {  }
.const-name { font-weight: bold; }

/* Syntax highlighting */

.src-code {  border: 1px solid #336699; padding: 1em; background-color: #EEEEEE; }
*[class="src-code"], *[class="listing"], *[class="example"] { line-height : 0.5em }

.src-comm { color: #666666; }
.src-id {  }
.src-inc { color: #0000FF; }
.src-key { color: #0000FF; }
.src-num { color: #CC0000; }
.src-str { color: #66cccc; }
.src-sym { font-weight: bold; }
.src-var { }

.src-php { font-weight: bold; }

.src-doc { color: #009999 }
.src-doc-close-template { color: #0000FF }
.src-doc-coretag { color: #0099FF; font-weight: bold }
.src-doc-inlinetag { color: #0099FF }
.src-doc-internal { color: #6699cc }
.src-doc-tag { color: #0080CC }
.src-doc-template { color: #0000FF }
.src-doc-type { font-style: italic }
.src-doc-var { font-style: italic }

.tute-tag { color: #009999 }
.tute-attribute-name { color: #0000FF }
.tute-attribute-value { color: #0099FF }
.tute-entity { font-weight: bold; }
.tute-comment { font-style: italic }
.tute-inline-tag { color: #636311; font-weight: bold }

/* tutorial */

.authors {  }
.author { font-style: italic; font-weight: bold }
.author-blurb { margin: .5em 0em .5em 2em; font-size: 85%; font-weight: normal; font-style: normal }
.example { background-color: #DDDDDD; border: 1px solid #999999; padding: .5em; }
.listing { background-color: #DDDDDD; border: 1px solid #999999; padding: .5em; white-space: nowrap; }
.release-info { font-size: 85%; font-style: italic; margin: 1em 0em }
.ref-title-box {  }
.ref-title {  }
.ref-purpose { font-style: italic; color: #666666 }
.ref-synopsis {  }
.title { font-weight: bold; border-bottom: 1px solid #888888; color: #888888;  }
.cmd-synopsis { margin: 1em 0em }
.cmd-title { font-weight: bold }
.toc { margin-left: 2em; padding-left: 0em }
</style>
			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
		</head>
		<body>
			<div class="page-body">
<h2 class="class-name">Class script_timer</h2>

<a name="sec-description"></a>
<div class="info-box">
	<div class="info-box-title">Description</div>
	<div class="nav-bar">
					<span class="disabled">Description</span> |
													<a href="#sec-var-summary">Vars</a> (<a href="#sec-vars">details</a>)
						|											<a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)

					</div>
	<div class="info-box-body">
        		<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Script timing class</p>
<p class="description"><p>Records the time it takes various parts of your script to run and displays  the results in a table so you can easily analyse which parts of your script  may need optimization.</p><p>With script timing you will always have some overhead for the taking of the  measurements and processing thereof.<br />  This class minimizes that overhead by excluding virtually all processing within  this class from your timing calculations.</p><p>*********************************************************************<br />  <strong>Features</strong><br />  *********************************************************************</p><p><ul><li>Add markers recorded before class instantiation</li><li>Temporarily pause the timer</li><li>Group markers by script</li><li>Optionally add subtotals per script (group)</li><li>Uses bcmath functions whenever possible for better calculation precision</li><li>Adjustable precision for the calculations</li><li>Adjustable precision for the output</li><li>Provides the following measurements:<br />
 		* run time for the marker (excluding processing by this class)<br />
 		* run time for the marker as a percentage of the total run time<br />
 		* cumulative run time up to the marker<br />
 		* cumulative percentage</li><li>Choose how you want to receive the results:<br />
 		* a two-dimentional array so you can process the results yourself<br />
 		* a html string which you can assign to whichever templating system you use<br />
 		* output straight to screen as a table</li><li>HTML output can easily be adjusted to your liking as the html used is contained in a template<br />
 		* the html can be adjusted in the template file (./templates/script_timing.tpl)<br />
 		* both the table as well as the rows are tagged with class names, through the use
 		  of CSS you can easily change the appearance of the table (as done in the example file)</li></ul>  *********************************************************************<br />  <strong>Basics on how to use the class</strong><br />  *********************************************************************</p><p>Include and instantiate the class :  <pre><ol><code><pre><li> <span class="src-inc">include_once</span><span class="src-sym">( </span><span class="src-str">'script_timer.inc.php' </span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li> <span class="src-var">$timer </span>= <span class="src-key">new </span><a href="../script_timer/script_timer.html#methodscript_timer">script_timer</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
</pre></code></ol></pre></p><p>Start the timer :  <pre><ol><code><pre><li> <span class="src-var">$timer</span><span class="src-sym">-&gt;</span><a href="../script_timer/script_timer.html#methodstart_timer">start_timer</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
</pre></code></ol></pre></p><p>Set a marker :  <pre><ol><code><pre><li> <span class="src-var">$timer</span><span class="src-sym">-&gt;</span><a href="../script_timer/script_timer.html#methodset_marker">set_marker</a><span class="src-sym">( </span><span class="src-str">'task x done' </span><span class="src-sym">)</span><span class="src-sym">;</span></li>
</pre></code></ol></pre></p><p>Optionally add a script (group) name to group a set of tasks together :  <pre><ol><code><pre><li> <span class="src-var">$timer</span><span class="src-sym">-&gt;</span><a href="../script_timer/script_timer.html#methodset_marker">set_marker</a><span class="src-sym">( </span><span class="src-str">'task y done'</span><span class="src-sym">, </span><span class="src-str">'sub script y' </span><span class="src-sym">)</span><span class="src-sym">;</span></li>
</pre></code></ol></pre></p><p>Optionally pause the script after a marker:  <pre><ol><code><pre><li> <span class="src-var">$timer</span><span class="src-sym">-&gt;</span><a href="../script_timer/script_timer.html#methodset_marker">set_marker</a><span class="src-sym">( </span><span class="src-str">'task z done'</span><span class="src-sym">, </span><span class="src-str">'script z'</span><span class="src-sym">, </span><span class="src-id">true </span><span class="src-sym">)</span><span class="src-sym">;</span></li>
</pre></code></ol></pre>   ... Do something you don't want timed ...<br />  Unpause the timer when you want to start timing again  <pre><ol><code><pre><li> <span class="src-var">$timer</span><span class="src-sym">-&gt;</span><a href="../script_timer/script_timer.html#methodunpause">unpause</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
</pre></code></ol></pre></p><p>Retrieve the results :</p><p>Method 1a - as a two-dimentional array without subtotals:  <pre><ol><code><pre><li> <span class="src-var">$timer</span><span class="src-sym">-&gt;</span><a href="../script_timer/script_timer.html#methodend_timer">end_timer</a><span class="src-sym">( </span><span class="src-id">false </span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li> <span class="src-var">$timer_array </span>= <span class="src-var">$timer</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../script_timer/script_timer.html#var$scripttiming">scripttiming</a></span><span class="src-sym">;</span></li>
</pre></code></ol></pre></p><p>Method 1b - as a two-dimentional array with subtotals and custom marker name for the end marker:  <pre><ol><code><pre><li> <span class="src-var">$timer</span><span class="src-sym">-&gt;</span><a href="../script_timer/script_timer.html#methodend_timer">end_timer</a><span class="src-sym">( </span><span class="src-id">true</span><span class="src-sym">, </span><span class="src-str">'My end marker name'</span><span class="src-sym">, </span><span class="src-str">'My script name' </span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li> <span class="src-var">$timer_array </span>= <span class="src-var">$timer</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../script_timer/script_timer.html#var$scripttiming">scripttiming</a></span><span class="src-sym">;</span></li>
</pre></code></ol></pre></p><p>Method 2 - as a html string :  (example uses a precision of 6 digits and ISO-8859-1 encoding for the html string):  <pre><ol><code><pre><li> <span class="src-var">$html </span>= <span class="src-var">$timer</span><span class="src-sym">-&gt;</span><a href="../script_timer/script_timer.html#methodget_output">get_output</a><span class="src-sym">( </span><span class="src-id">false</span><span class="src-sym">, </span><span class="src-num">6</span><span class="src-sym">, </span><span class="src-str">'ISO-8859-1' </span><span class="src-sym">)</span><span class="src-sym">;</span></li>
</pre></code></ol></pre></p><p>Method 3 - output to screen :  (example uses a precision of 4 digits and the default (utf-8) encoding for the html string):  <pre><ol><code><pre><li> <span class="src-var">$timer</span><span class="src-sym">-&gt;</span><a href="../script_timer/script_timer.html#methodget_output">get_output</a><span class="src-sym">( </span><span class="src-id">true</span><span class="src-sym">, </span><span class="src-num">4 </span><span class="src-sym">)</span><span class="src-sym">;</span></li>
</pre></code></ol></pre></p><p>Oftentimes you may want to start timing a script before you include any files /  classes.<br />  This class lets you do so and this is how:</p><p>At the start of your script, record a start time:  <pre><ol><code><pre><li> <span class="src-var">$start </span>= <a href="http://www.php.net/microtime">microtime</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
</pre></code></ol></pre></p><p>Store any markers you want in an array:  <pre><ol><code><pre><li> <span class="src-var">$time_array</span><span class="src-sym">[</span><span class="src-sym">] </span>= <span class="src-key">array</span><span class="src-sym">( </span><a href="http://www.php.net/microtime">microtime</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">, </span><span class="src-str">'Start up task x done'</span><span class="src-sym">, </span><span class="src-str">'optional script name' </span><span class="src-sym">)</span><span class="src-sym">;</span></li>
</pre></code></ol></pre></p><p>Once you have included and instantiated the class, pass these markers and your start time  to the class object:  <pre><ol><code><pre><li> <span class="src-var">$timer</span><span class="src-sym">-&gt;</span><a href="../script_timer/script_timer.html#methodadd_markers">add_markers</a><span class="src-sym">( </span><span class="src-var">$time_array</span><span class="src-sym">, </span><span class="src-var">$start </span><span class="src-sym">)</span><span class="src-sym">;</span></li>
</pre></code></ol></pre>  Do not call the <a href="../script_timer/script_timer.html#methodstart_timer">start_timer()</a> method after this as <a href="../script_timer/script_timer.html#methodadd_markers">add_markers()</a> will  start your timer at the first recorded time or at the start time if you pass one.</p><p>After adding your manually recorded markers, you can use the class like above to set additional  markers and get the results.</p><p>After using the timer, you may want to clean up, for instance if you want to time  several scripts seperately :  <pre><ol><code><pre><li> <span class="src-var">$timer</span><span class="src-sym">-&gt;</span><a href="../script_timer/script_timer.html#methodreset">reset</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
</pre></code></ol></pre></p><p></p><p>*********************************************************************<br />  <strong>Version management information</strong><br />  *********************************************************************</p><p><ul><li>v1.0 First public release</li></ul>  *********************************************************************</p></p>
	<ul class="tags">
				<li><span class="field">example:</span> <a href="../__examplesource/exsource_raries_benchmark_examples_script_timer_example.php_ef2f67e118bd8018ae1fb00baf5865dc.html">example</a></li>
				<li><span class="field">link:</span> <a href="http://www.php.net/function.microtime">http://www.php.net/function.microtime</a></li>
				<li><span class="field">link:</span> <a href="http://www.phpbb.com/kb/article.php?article_id=200">phpbb template tutorial</a></li>
				<li><span class="field">uses:</span> phpBB's - template class for displaying information / parsing the html to string</li>
				<li><span class="field">license:</span> <a href="http://www.opensource.org/licenses/lgpl-license.php">GNU Lesser General Public License</a></li>
				<li><span class="field">license:</span> <a href="http://opensource.org/licenses/academic">Academic Free License Version 1.2</a></li>
				<li><span class="field">version:</span> 1.0</li>
				<li><span class="field">since:</span> 2006-09-08 // Last changed: by Juliette Reinders Folmer</li>
				<li><span class="field">copyright:</span> ©2006 <a href="http://www.adviesenzo.nl/">Advies en zo</a>,                  &lt;hide@address.com&gt;</li>
				<li><span class="field">author:</span> Juliette Reinders Folmer, Advies en zo - &lt;<a href="mailto:hide@address.com">hide@address.com</a>&gt;</li>
			</ul>
		<p class="notes">
			Located in <a class="field" href="_libraries_benchmark_script_timer_inc_php.html">/script_timer.inc.php</a> (line <span class="field">140</span>)
		</p>


		<pre></pre>

			</div>
</div>



	<a name="sec-var-summary"></a>
	<div class="info-box">
		<div class="info-box-title">Variable Summary</span></div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
						<span class="disabled">Vars</span> (<a href="#sec-vars">details</a>)
							|
									<a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)

								</div>
		<div class="info-box-body">
			<div class="var-summary">
								<div class="var-title">
					<span class="var-type">int</span>
					<a href="#$calc_precision" title="details" class="var-name">$calc_precision</a>
				</div>
								<div class="var-title">
					<span class="var-type">array</span>
					<a href="#$lang_strings" title="details" class="var-name">$lang_strings</a>
				</div>
								<div class="var-title">
					<span class="var-type">string</span>
					<a href="#$output_encoding" title="details" class="var-name">$output_encoding</a>
				</div>
								<div class="var-title">
					<span class="var-type">int</span>
					<a href="#$output_precision" title="details" class="var-name">$output_precision</a>
				</div>
								<div class="var-title">
					<span class="var-type">array</span>
					<a href="#$scripttiming" title="details" class="var-name">$scripttiming</a>
				</div>
								<div class="var-title">
					<span class="var-type">bool</span>
					<a href="#$subtotals_added" title="details" class="var-name">$subtotals_added</a>
				</div>
								<div class="var-title">
					<span class="var-type">bool</span>
					<a href="#$timer_paused" title="details" class="var-name">$timer_paused</a>
				</div>
								<div class="var-title">
					<span class="var-type">string|float</span>
					<a href="#$timer_total" title="details" class="var-name">$timer_total</a>
				</div>
							</div>
		</div>
	</div>

	<a name="sec-method-summary"></a>
	<div class="info-box">
		<div class="info-box-title">Method Summary</span></div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
																		<a href="#sec-var-summary">Vars</a> (<a href="#sec-vars">details</a>)

				|
						<span class="disabled">Methods</span> (<a href="#sec-methods">details</a>)
		</div>
		<div class="info-box-body">
			<div class="method-summary">

				<div class="method-definition">
											<span class="method-result"><a href="../script_timer/script_timer.html">script_timer</a></span>
										<a href="#script_timer" title="details" class="method-name">script_timer</a>
											([<span class="var-type">int</span>&nbsp;<span class="var-name">$calc_precision</span> = <span class="var-default">null</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$auto_start</span> = <span class="var-default">false</span>])
									</div>

				<div class="method-definition">
											<span class="method-result">void</span>
										<a href="#add_markers" title="details" class="method-name">add_markers</a>
											(<span class="var-type">array</span>&nbsp;<span class="var-name">$marker_array</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$start_time</span> = <span class="var-default">null</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$add_marker_for_interim</span> = <span class="var-default">true</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$marker_name</span> = <span class="var-default">null</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$script_name</span> = <span class="var-default">null</span>])
									</div>

				<div class="method-definition">
											<span class="method-result">void</span>
										<a href="#end_timer" title="details" class="method-name">end_timer</a>
											([<span class="var-type">bool</span>&nbsp;<span class="var-name">$add_subtotals</span> = <span class="var-default">false</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$marker_name</span> = <span class="var-default">null</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$script_name</span> = <span class="var-default">null</span>])
									</div>

				<div class="method-definition">
											<span class="method-result">string|bool</span>
										<a href="#get_output" title="details" class="method-name">get_output</a>
											([<span class="var-type">bool</span>&nbsp;<span class="var-name">$display</span> = <span class="var-default">false</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$precision</span> = <span class="var-default">null</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$encoding</span> = <span class="var-default">null</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$add_subtotals</span> = <span class="var-default">null</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$marker_name</span> = <span class="var-default">null</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$script_name</span> = <span class="var-default">null</span>])
									</div>

				<div class="method-definition">
											<span class="method-result">void</span>
										<a href="#reset" title="details" class="method-name">reset</a>
										()
									</div>

				<div class="method-definition">
											<span class="method-result">void</span>
										<a href="#set_marker" title="details" class="method-name">set_marker</a>
											(<span class="var-type">string</span>&nbsp;<span class="var-name">$marker_name</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$script_name</span> = <span class="var-default">null</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$pause_timer</span> = <span class="var-default">false</span>])
									</div>

				<div class="method-definition">
											<span class="method-result">void</span>
										<a href="#start_timer" title="details" class="method-name">start_timer</a>
										()
									</div>

				<div class="method-definition">
											<span class="method-result">void</span>
										<a href="#unpause" title="details" class="method-name">unpause</a>
										()
									</div>
							</div>
		</div>
	</div>

	<a name="sec-vars"></a>
	<div class="info-box">
		<div class="info-box-title">Variables</div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
										<a href="#sec-var-summary">Vars</a> (<span class="disabled">details</span>)


										|
									<a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)

					</div>
		<div class="info-box-body">
			<a name="var$calc_precision" id="$calc_precision"><!-- --></A>
<div class="evenrow">

	<div class="var-header">
		<span class="var-title">
			<span class="var-type">int</span>
			<span class="var-name">$calc_precision</span>
			 = <span class="var-default"> 10</span>			(line <span class="line-number">164</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Precision for the bcmath functions and floats</p>
<p class="description"><p>Can be set through the class instantiation method</p></p>
	<ul class="tags">
				<li><span class="field">link:</span> <a href="http://www.php.net/ini.core">http://www.php.net/ini.core</a></li>
				<li><span class="field">link:</span> <a href="http://www.php.net/ref.bc">http://www.php.net/ref.bc</a></li>
			</ul>





</div>
<a name="var$lang_strings" id="$lang_strings"><!-- --></A>
<div class="oddrow">

	<div class="var-header">
		<span class="var-title">
			<span class="var-type">array</span>
			<span class="var-name">$lang_strings</span>
			 = <span class="var-default">array(
<br />		'subtotal'	=&gt;	'Subtotal of :', 		// used in end_timer()
<br />		'end_timer'	=&gt;	'End of script timing', // used in end_timer()
<br />		'interim_marker'	=&gt;	'Processing between setting of last manual marker and calling add_markers method' 							// used in add_markers()
<br />	)</span>			(line <span class="line-number">319</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Language strings used by the class</p>
<p class="description"><p>Only contains language strings which *may* be used in the output.  Except for <em>subtotal</em>, they can be overruled by setting optional parameters when calling the  related methods.</p><p>The only other language strings in this class are error messages and those are  hard coded in English for obvious reasons.</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodadd_markers">script_timer::add_markers()</a></li>
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodend_timer">script_timer::end_timer()</a></li>
			</ul>





</div>
<a name="var$output_encoding" id="$output_encoding"><!-- --></A>
<div class="evenrow">

	<div class="var-header">
		<span class="var-title">
			<span class="var-type">string</span>
			<span class="var-name">$output_encoding</span>
			 = <span class="var-default"> 'utf-8'</span>			(line <span class="line-number">188</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Default character encoding for output of results</p>
<p class="description"><p>Can be overruled by setting the $encoding parameter in the <a href="../script_timer/script_timer.html#methodget_output">get_output()</a> method</p></p>
	<ul class="tags">
				<li><span class="field">link:</span> <a href="http://www.php.net/function.htmlspecialchars">http://www.php.net/function.htmlspecialchars</a></li>
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodget_output">script_timer::get_output()</a></li>
			</ul>





</div>
<a name="var$output_precision" id="$output_precision"><!-- --></A>
<div class="oddrow">

	<div class="var-header">
		<span class="var-title">
			<span class="var-type">int</span>
			<span class="var-name">$output_precision</span>
			 = <span class="var-default"> 4</span>			(line <span class="line-number">177</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Default precision for output of results</p>
<p class="description"><p>Can be overruled by setting the $precision parameter in the <a href="../script_timer/script_timer.html#methodget_output">get_output()</a> method</p></p>
	<ul class="tags">
				<li><span class="field">link:</span> <a href="http://www.php.net/function.round">http://www.php.net/function.round</a></li>
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodget_output">script_timer::get_output()</a></li>
			</ul>





</div>
<a name="var$scripttiming" id="$scripttiming"><!-- --></A>
<div class="evenrow">

	<div class="var-header">
		<span class="var-title">
			<span class="var-type">array</span>
			<span class="var-name">$scripttiming</span>
			 = <span class="var-default">array()</span>			(line <span class="line-number">272</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Result array for script timing</p>
<p class="description"><p>The result array will (eventually) contain a two-dimentional array of information.  Each record will hold the following information:  <pre>[#] => array(
 	[microtime_end]		=> string	microtime end time for marker
 	[microtime_elapsed]	=> string|float	microtime between start and end
 						for this marker
 	[microtime_start]	=> string	microtime start time for timing
 						of this marker
 	[marker_name]		=> string	marker name
 	[script_name] 		=> string|null	[optional] script name
 	[perc_elapsed]		=> string|float	percentage of this script part
 						compared to the whole script
 	[subtotal]		=> string|float	microtime since beginning of timing
 	[cum_perc]		=> string|float	cumulative percentage script run since
 						beginning of timing
 )</pre></p><p>Whether calculated figures are stored as a string or float depends on whether  the bcmath extension is loaded.</p></p>





</div>
<a name="var$subtotals_added" id="$subtotals_added"><!-- --></A>
<div class="oddrow">

	<div class="var-header">
		<span class="var-title">
			<span class="var-type">bool</span>
			<span class="var-name">$subtotals_added</span>
						(line <span class="line-number">302</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Variable which contains the setting used for $add_subtotals in  the <a href="../script_timer/script_timer.html#methodend_timer">end_timer()</a> method.</p>





</div>
<a name="var$timer_paused" id="$timer_paused"><!-- --></A>
<div class="evenrow">

	<div class="var-header">
		<span class="var-title">
			<span class="var-type">bool</span>
			<span class="var-name">$timer_paused</span>
			 = <span class="var-default"> false</span>			(line <span class="line-number">281</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Variable to keep track of whether the timer is in pause mode or not</p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodunpause">script_timer::unpause()</a></li>
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodset_marker">script_timer::set_marker()</a></li>
			</ul>





</div>
<a name="var$timer_total" id="$timer_total"><!-- --></A>
<div class="oddrow">

	<div class="var-header">
		<span class="var-title">
			<span class="var-type">string|float</span>
			<span class="var-name">$timer_total</span>
			 = <span class="var-default"> 0</span>			(line <span class="line-number">245</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Sum of the timings taken (so far)</p>
<p class="description"><p>Whether this is a string or float depends on whether the bcmath extension is loaded.</p></p>





</div>

		</div>
	</div>

	<a name="sec-methods"></a>
	<div class="info-box">
		<div class="info-box-title">Methods</div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
															<a href="#sec-var-summary">Vars</a> (<a href="#sec-vars">details</a>)
																	<a href="#sec-method-summary">Methods</a> (<span class="disabled">details</span>)

		</div>
		<div class="info-box-body">
			<A NAME='method_detail'></A>
<a name="methodscript_timer" id="script_timer"><!-- --></a>
<div class="evenrow">

	<div class="method-header">
		<span class="method-title">Constructor script_timer</span> (line <span class="line-number">354</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Class instantiation</p>
<p class="description"><p><ul><li>Checks for the bcmath extension and throws a warning if not found</li><li>Fetches the directory this script resides in for later use</li><li>[Optionally] Sets the calculation precision for the timer class.<br />
 		If the $calc_precision parameter is not set, the <a href="../script_timer/script_timer.html#var$calc_precision">default setting</a>
         will be used.</li><li>[Optionally] Starts the timer<br />
         Do not use this feature in combination with the <a href="../script_timer/script_timer.html#methodadd_markers">add_markers()</a> method
         (which will start the timer automatically) !<br />
         You can also manually start the timer at a later timer with <a href="../script_timer/script_timer.html#methodstart_timer">start_timer()</a></li></ul></p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodstart_timer">script_timer::start_timer()</a></li>
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodadd_markers">script_timer::add_markers()</a></li>
			</ul>

	<div class="method-signature">
		<span class="method-result"><a href="../script_timer/script_timer.html">script_timer</a></span>
		<span class="method-name">
			script_timer
		</span>
					([<span class="var-type">int</span>&nbsp;<span class="var-name">$calc_precision</span> = <span class="var-default">null</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$auto_start</span> = <span class="var-default">false</span>])
			</div>

			<ul class="parameters">
					<li>
				<span class="var-type">int</span>
				<span class="var-name">$calc_precision</span><span class="var-description">: [optional]</span>			</li>
					<li>
				<span class="var-type">bool</span>
				<span class="var-name">$auto_start</span><span class="var-description">: [optional]    whether or not to start the timer at instantiation                                          Defaults to <em>false</em>.</span>			</li>
				</ul>


	</div>
<a name="methodadd_markers" id="add_markers"><!-- --></a>
<div class="oddrow">

	<div class="method-header">
		<span class="method-title">add_markers</span> (line <span class="line-number">477</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Add breakpoint microtime markers which were recorded outside of this class</p>
<p class="description"><p>Typical use: when you start your script, you first validate and normalize some data  before including any classes.  If you want to also time this first part of the script (i.e. before this class was  instantiated), you will need to record some breakpoints yourself.</p><p>Record those breakpoints like this:  <pre><ol><code><pre><li><span class="src-var">$marker_array</span><span class="src-sym">[</span><span class="src-sym">] </span>= <span class="src-key">array</span><span class="src-sym">( </span><a href="http://www.php.net/microtime">microtime</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">, </span><span class="src-str">'marker name'</span><span class="src-sym">, </span><span class="src-str">'optional script name' </span><span class="src-sym">)</span><span class="src-sym">;</span></li>
</pre></code></ol></pre></p><p>Using this method, you can then later (once the class is instantiated) add those  recorded times to the class object.</p><p>If you use this method, call this (straight) after you instantiate the class and before  recording additional markers using the <a href="../script_timer/script_timer.html#methodset_marker">set_marker()</a> method.</p><p>This method will start the timer automatically. Do not call the <a href="../script_timer/script_timer.html#methodstart_timer">start_timer()</a> method.</p><p>This method will (optionally) auto-add an extra marker for the script part between  the last marker passed and the call to this method. You can optionally set  your own $marker_name (and - again optionally - $script_name) for this extra marker.<br />  If you choose not to add the extra marker, the timing for the next marker will be corrected for  the processing time taken by this method call.</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodset_marker">script_timer::set_marker()</a></li>
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodstart_timer">script_timer::start_timer()</a></li>
			</ul>

	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			add_markers
		</span>
					(<span class="var-type">array</span>&nbsp;<span class="var-name">$marker_array</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$start_time</span> = <span class="var-default">null</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$add_marker_for_interim</span> = <span class="var-default">true</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$marker_name</span> = <span class="var-default">null</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$script_name</span> = <span class="var-default">null</span>])
			</div>

			<ul class="parameters">
					<li>
				<span class="var-type">array</span>
				<span class="var-name">$marker_array</span><span class="var-description">: multi-dimentional array using the following structure  <pre><ol><code><pre><li><span class="src-key">array</span><span class="src-sym">(</span></li>
<li>     <span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">] </span>=&gt;    <span class="src-key">array</span><span class="src-sym">(</span></li>
<li>         <span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">] </span>=&gt;    <span class="src-id">string    recorded </span><a href="http://www.php.net/microtime">microtime</a></li>
<li>         <span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">] </span>=&gt;    <span class="src-id">string    breakpoint marker name</span></li>
<li>         <span class="src-sym">[</span><span class="src-num">2</span><span class="src-sym">] </span>=&gt;    <span class="src-id">string    </span><span class="src-sym">[</span><span class="src-id">optional</span><span class="src-sym">] </span><span class="src-id">script name</span></li>
<li>     <span class="src-sym">)</span><span class="src-sym">,</span></li>
<li>     <span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]    </span>=&gt;    <span class="src-key">array</span><span class="src-sym">( </span>....<span class="src-sym">)</span><span class="src-sym">,</span></li>
<li>     .....</li>
<li> <span class="src-sym">)</span><span class="src-sym">;</span></li>
</pre></code></ol></pre></span>			</li>
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$start_time</span><span class="var-description">: [optional]    recorded microtime for start of script timing                                          If not passed, the microtime of the first record                                          in the array will be used as start time and the                                          first record will have an elapsed time of 0.</span>			</li>
					<li>
				<span class="var-type">bool</span>
				<span class="var-name">$add_marker_for_interim</span><span class="var-description">: [optional]    whether or not to add a marker for the                                          time passed between the last marker in the array and                                          the call to this method. Defaults to <em>true</em>.<br />                                          If set to <em>false</em>, the next marker will measure the                                          time between the last marker and itself including the call                                          to this method, though largely - but not completely -                                          corrected for the time this method takes to run.</span>			</li>
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$marker_name</span><span class="var-description">: [optional]    name for the (optional) interim marker,                                          default to the markername in                                          <a href="../script_timer/script_timer.html#var$lang_strings">$lang_strings['interim_marker']</a></span>			</li>
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$script_name</span><span class="var-description">: [optional]    name for the script / group for the                                          (optional) interim marker, defaults to null (i.e. no script                                          / group name)</span>			</li>
				</ul>


	</div>
<a name="methodend_timer" id="end_timer"><!-- --></a>
<div class="evenrow">

	<div class="method-header">
		<span class="method-title">end_timer</span> (line <span class="line-number">679</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">End timer and add additional measurements to the result array</p>
<p class="description"><p>If the timer is not currently in pause mode, an end marker will be added. You can optionally  specify a marker name (and - again optionally - script name) for the end marker.</p><p>Measurements added are: <ul><li>Run time for the marker</li><li>Percentage of current marker compared to complete script</li><li>Run time of script up to the marker</li><li>Cumulative percentage of run time up to the marker compared to the complete script</li></ul>  Additionally (and optionally) subtotals can be added for groups of markers, so indicated  when they where set by script name.</p><p>If you want to display / retrieve as html string the results of your timer as soon  as you end the timer, you can use the <a href="../script_timer/script_timer.html#methodget_output">get_output()</a> method which will end  the timer automatically.</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodget_output">script_timer::get_output()</a></li>
			</ul>

	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			end_timer
		</span>
					([<span class="var-type">bool</span>&nbsp;<span class="var-name">$add_subtotals</span> = <span class="var-default">false</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$marker_name</span> = <span class="var-default">null</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$script_name</span> = <span class="var-default">null</span>])
			</div>

			<ul class="parameters">
					<li>
				<span class="var-type">bool</span>
				<span class="var-name">$add_subtotals</span><span class="var-description">: [optional] whether or not to add subtotals for                                          groups of markers by script name.                                          Defaults to <em>false</em>.</span>			</li>
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$marker_name</span><span class="var-description">: [optional] marker name for the 'script timing ended' marker,                                          default to the markername in                                          <a href="../script_timer/script_timer.html#var$lang_strings">$lang_strings['end_timer']</a>.</span>			</li>
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$script_name</span><span class="var-description">: [optional] script name for this last marker, defaults to null</span>			</li>
				</ul>


	</div>
<a name="methodget_output" id="get_output"><!-- --></a>
<div class="oddrow">

	<div class="method-header">
		<span class="method-title">get_output</span> (line <span class="line-number">799</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Retrieve the timer output either as a html string or directly printed to screen</p>
<p class="description"><p>Please refer to <a href="../script_timer/script_timer.html#methodend_timer">end_timer()</a> for information on how (and why) to set the optional  $add_subtotals, $marker_name and $script_name parameters</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> returns the html string or true if output to screen was successful</li>
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodend_timer">script_timer::end_timer()</a></li>
			</ul>

	<div class="method-signature">
		<span class="method-result">string|bool</span>
		<span class="method-name">
			get_output
		</span>
					([<span class="var-type">bool</span>&nbsp;<span class="var-name">$display</span> = <span class="var-default">false</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$precision</span> = <span class="var-default">null</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$encoding</span> = <span class="var-default">null</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$add_subtotals</span> = <span class="var-default">null</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$marker_name</span> = <span class="var-default">null</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$script_name</span> = <span class="var-default">null</span>])
			</div>

			<ul class="parameters">
					<li>
				<span class="var-type">bool</span>
				<span class="var-name">$display</span><span class="var-description">: [optional] whether to return the output to the screen                                      or as a string<br />                                      <em>false</em> returns a html string<br />                                      <em>true</em> prints the results to screen<br />                                      Defaults to <em>false</em>.</span>			</li>
					<li>
				<span class="var-type">int</span>
				<span class="var-name">$precision</span><span class="var-description">: [optional] output precision of microtime values<br />                                      Defaults to <a href="../script_timer/script_timer.html#var$output_precision">$output_precision</a></span>			</li>
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$encoding</span><span class="var-description">: [optional] character encoding for the html output<br />                                      Defaults to <a href="../script_timer/script_timer.html#var$output_encoding">$output_encoding</a></span>			</li>
					<li>
				<span class="var-type">bool</span>
				<span class="var-name">$add_subtotals</span><span class="var-description">: [optional] only used if the timer was not previously stopped</span>			</li>
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$marker_name</span><span class="var-description">: [optional] only used if the timer was not previously stopped</span>			</li>
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$script_name</span><span class="var-description">: [optional] only used if the timer was not previously stopped</span>			</li>
				</ul>


	</div>
<a name="methodreset" id="reset"><!-- --></a>
<div class="evenrow">

	<div class="method-header">
		<span class="method-title">reset</span> (line <span class="line-number">871</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Reset all result variables</p>

	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			reset
		</span>
				()
			</div>



	</div>
<a name="methodset_marker" id="set_marker"><!-- --></a>
<div class="oddrow">

	<div class="method-header">
		<span class="method-title">set_marker</span> (line <span class="line-number">577</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Record the time for a breakpoint in your script</p>
<p class="description"><p>Sets the marker for the breakpoint called $marker_name</p><p>If you use/include a lot of scripts in your page, you may want to set the optional  parameter $script_name to record in which script the breakpoint resides.<br />  Obviously you can also use $script_name to group sequential related parts of your script.<br />  If you use the $script_name variable, you can then receive subtotals per script (group)  in your timer results.</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodadd_markers">script_timer::add_markers()</a></li>
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodstart_timer">script_timer::start_timer()</a></li>
			</ul>

	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			set_marker
		</span>
					(<span class="var-type">string</span>&nbsp;<span class="var-name">$marker_name</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$script_name</span> = <span class="var-default">null</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$pause_timer</span> = <span class="var-default">false</span>])
			</div>

			<ul class="parameters">
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$marker_name</span><span class="var-description">: name for your breakpoint so you recognize it later</span>			</li>
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$script_name</span><span class="var-description">: [optional]    name of the current script or group</span>			</li>
					<li>
				<span class="var-type">bool</span>
				<span class="var-name">$pause_timer</span><span class="var-description">: [optional]    pause the timer after setting this marker                                      Defaults to <em>false</em>, i.e. don't pause the timer.</span>			</li>
				</ul>


	</div>
<a name="methodstart_timer" id="start_timer"><!-- --></a>
<div class="evenrow">

	<div class="method-header">
		<span class="method-title">start_timer</span> (line <span class="line-number">398</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Start script timing</p>
<p class="description"><p>This is optional.<br />  Alternatively the first time you call the <a href="../script_timer/script_timer.html#methodset_marker">set_marker()</a> method, script timing will  automatically be started.<br />  <em>Take note</em>: Starting the timing via the <a href="../script_timer/script_timer.html#methodset_marker">set_marker()</a> method will cause the timing  for the first marker to be 0.</p><p>If you use the <a href="../script_timer/script_timer.html#methodadd_markers">add_markers()</a> method to add markers recorded before class instantiation,  the start time will be set through that method. You should not use this method if you use  <a href="../script_timer/script_timer.html#methodadd_markers">add_markers()</a>.</p><p><strong>Important:</strong><br />  Starting the timer - independently of which method you use - will destroy all previously  recorded markers as a new timer is presumed.</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodreset">script_timer::reset()</a></li>
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodset_marker">script_timer::set_marker()</a></li>
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodadd_markers">script_timer::add_markers()</a></li>
			</ul>

	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			start_timer
		</span>
				()
			</div>



	</div>
<a name="methodunpause" id="unpause"><!-- --></a>
<div class="oddrow">

	<div class="method-header">
		<span class="method-title">unpause</span> (line <span class="line-number">625</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Unpause the timer</p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../script_timer/script_timer.html#methodset_marker">script_timer::set_marker()</a></li>
			</ul>

	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			unpause
		</span>
				()
			</div>



	</div>

		</div>
	</div>


	<p class="notes" id="credit">
		Documentation generated on Fri, 08 Sep 2006 23:04:36 +0200 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.3.0RC3</a>
	</p>
	</div></body>
</html>
Return current item: Script timer