Quick Selenium RC Runner Script (updated)

<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="">'BADWEIGHT'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="">'GOODWEIGHT'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="">'BADMULTIPLIER'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">150</span><span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="">'BADTIMEOUT'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="">'SLOWDEVIATIONS'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <span style="">'C:Program FilesICWhomenagiosremoteselenium.txt'</span>;
&nbsp;
<span style="color: #000088;">$execCommand</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;phpunit.bat selenium.php&quot;</span>;
<span style="color: #000088;">$trial</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;
<span style="color: #000000; font-weight: bold;">function</span> logToFile<span style="color: #009900;">&#40;</span><span style="color: #000088;">$somecontent</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<a href="http://www.php.net/global"><span style="color: #990000;">global</span></a> <span style="color: #000088;">$filename</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_writable"><span style="color: #990000;">is_writable</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/fopen"><span style="color: #990000;">fopen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #339933;">,</span> <span style="">'a'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			 <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a> <span style="color: #0000ff;">&quot;Cannot open file ($filename)&quot;</span>;
			 <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a>;
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/fwrite"><span style="color: #990000;">fwrite</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #339933;">,</span> <span style="color: #000088;">$somecontent</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #000000; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a> <span style="color: #0000ff;">&quot;Cannot write to file ($filename)&quot;</span>;
			<a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a>;
		<span style="color: #009900;">&#125;</span>
		<a href="http://www.php.net/fclose"><span style="color: #990000;">fclose</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a> <span style="color: #0000ff;">&quot;The file $filename is not writable&quot;</span>;
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> sd_square<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mean</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <a href="http://www.php.net/pow"><span style="color: #990000;">pow</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$mean</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>; <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> sd<span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">return</span> <a href="http://www.php.net/sqrt"><span style="color: #990000;">sqrt</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array_sum"><span style="color: #990000;">array_sum</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array_map"><span style="color: #990000;">array_map</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;sd_square&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$array</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array_fill"><span style="color: #990000;">array_fill</span></a><span style="color: #009900;">&#40;</span><span style="color:#800080;">0</span><span style="color: #339933;">,</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/array_sum"><span style="color: #990000;">array_sum</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> getStats<span style="color: #009900;">&#40;</span><span style="color: #000088;">$trials</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trials</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$trial</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$sum</span><span style="color: #339933;">+=</span><span style="color: #000088;">$trial</span><span style="color: #009900;">&#91;</span><span style="">'time'</span><span style="color: #009900;">&#93;</span>;
		<span style="color: #000088;">$timeArray</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$trial</span><span style="color: #009900;">&#91;</span><span style="">'time'</span><span style="color: #009900;">&#93;</span>;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$counter</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trials</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span><span style="color:#800080;">0</span><span style="color: #009900;">&#41;</span>?<a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trials</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">1</span>;
	<span style="color: #000088;">$average</span><span style="color: #339933;">=</span><a href="http://www.php.net/sprintf"><span style="color: #990000;">sprintf</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;%.2f&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$sum</span><span style="color: #339933;">/</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trials</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trials</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$stdDev</span><span style="color: #339933;">=</span><a href="http://www.php.net/sprintf"><span style="color: #990000;">sprintf</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;%.2f&quot;</span><span style="color: #339933;">,</span>sd<span style="color: #009900;">&#40;</span><span style="color: #000088;">$timeArray</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$stdDev</span><span style="color: #339933;">=</span><span style="color:#800080;">0.00</span>;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$average</span><span style="color: #339933;">,</span><span style="color: #000088;">$stdDev</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> stripOutliers<span style="color: #009900;">&#40;</span><span style="color: #000088;">$times</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$noOutlierArray</span><span style="color: #339933;">=</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
	<a href="http://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$avg</span><span style="color: #339933;">,</span><span style="color: #000088;">$stDev</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">=</span>getStats<span style="color: #009900;">&#40;</span><span style="color: #000088;">$times</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$times</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$lineItem</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$lineItem</span><span style="color: #009900;">&#91;</span><span style="">'time'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&lt;=</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$avg</span><span style="color: #339933;">+</span><span style="color: #000088;">$stDev</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$noOutlierArray</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="">'time'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$lineItem</span><span style="color: #009900;">&#91;</span><span style="">'time'</span><span style="color: #009900;">&#93;</span>;
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$noOutlierArray</span>;
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$flagCnt</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;
<span style="color: #000088;">$statCnt</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$output</span><span style="color: #339933;">=</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
	<a href="http://www.php.net/exec"><span style="color: #990000;">exec</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$execCommand</span><span style="color: #339933;">,</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #000088;">$time</span><span style="color: #339933;">=</span><a href="http://www.php.net/intval"><span style="color: #990000;">intval</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">6</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>; <span style="color: #666666; font-style: italic;">//parse seconds</span>
	<a href="http://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #339933;">,</span><span style="color: #000088;">$hud</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">=</span><a href="http://www.php.net/split"><span style="color: #990000;">split</span></a><span style="color: #009900;">&#40;</span><span style="">' '</span><span style="color: #339933;">,</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>; <span style="color: #666666; font-style: italic;">//parse status</span>
	<span style="color: #000088;">$status</span><span style="color: #339933;">=</span><a href="http://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #339933;">!=</span><span style="">'OK'</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$status</span><span style="color: #339933;">=</span><a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">,</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
		<span style="color: #000088;">$statCnt</span><span style="color: #339933;">+=</span>BADWEIGHT;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$statCnt</span><span style="color: #339933;">-=</span>GOODWEIGHT;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$resultArray</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$trial</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="">'time'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$time</span>;
	<span style="color: #000088;">$resultArray</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$trial</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="">'status'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$status</span>;
&nbsp;
	<a href="http://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$avg</span><span style="color: #339933;">,</span><span style="color: #000088;">$stDev</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">=</span>getStats<span style="color: #009900;">&#40;</span>stripOutliers<span style="color: #009900;">&#40;</span><span style="color: #000088;">$resultArray</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #000088;">$FLAG</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$time</span><span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$avg</span><span style="color: #339933;">+</span>SLOWDEVIATIONS<span style="color: #339933;">*</span><span style="color: #000088;">$stDev</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>?<span style="color: #0000ff;">&quot;SLOW&quot;</span><span style="color: #339933;">:</span><span style="">'OK'</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #339933;">!=</span><span style="">'OK'</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$FLAG</span><span style="color: #339933;">=</span><span style="">'WARNING! Bad Status '</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$FLAG</span><span style="color: #339933;">==</span><span style="">'SLOW'</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$flagCnt</span><span style="color: #339933;">+=</span>BADWEIGHT;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$flagCnt</span><span style="color: #339933;">-=</span>GOODWEIGHT;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$flagCnt</span><span style="color: #339933;">&lt;=</span><span style="color:#800080;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$flagCnt</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$statCnt</span><span style="color: #339933;">&lt;=</span><span style="color:#800080;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$statCnt</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$flagCnt</span><span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span>BADWEIGHT<span style="color: #339933;">*</span>BADMULTIPLIER<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$FLAG</span><span style="color: #339933;">=</span><span style="">'ERROR! TOO MANY SLOW TRANSACTIONS'</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$statCnt</span><span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span>BADWEIGHT<span style="color: #339933;">*</span>BADMULTIPLIER<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$FLAG</span><span style="color: #339933;">=</span><span style="">'ERROR! TOO MANY TRANSACTION FAILURES'</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$FLAG</span><span style="color: #339933;">==</span><span style="">'ERROR! TOO MANY TRANSACTION FAILURES'</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #000088;">$status</span><span style="color: #339933;">==</span><span style="">'OK'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000088;">$FLAG</span><span style="color: #339933;">=</span><span style="">'OK'</span>;<span style="color: #000088;">$flagCnt</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$FLAG</span><span style="color: #339933;">==</span><span style="">'ERROR! TOO MANY SLOW TRANSACTIONS'</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #000088;">$status</span><span style="color: #339933;">==</span><span style="">'OK'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000088;">$FLAG</span><span style="color: #339933;">=</span><span style="">'OK'</span>;<span style="color: #000088;">$flagCnt</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$lineItem</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${trial},&quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="">'d/m/Y H:i:s'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;,$time sec,$status,Avg:$avg,StdDev:$stDev,$FLAG,$flagCnt,$statCntn&quot;</span>;
	<a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lineItem</span><span style="color: #009900;">&#41;</span>;
	logToFile<span style="color: #009900;">&#40;</span><span style="color: #000088;">$lineItem</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$FLAG</span><span style="color: #339933;">!=</span><span style="">'OK'</span><span style="color: #009900;">&#41;</span>||<span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #339933;">!=</span><span style="">'OK'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <a href="http://www.php.net/sleep"><span style="color: #990000;">sleep</span></a><span style="color: #009900;">&#40;</span>BADTIMEOUT<span style="color: #009900;">&#41;</span>;
	<span style="color: #000088;">$trial</span>++;
<span style="color: #009900;">&#125;</span>

which will produce a text file like this:

C:xamppphp<span style="color: #000000; font-weight: bold;">&gt;</span>php runTests.php
0,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:06:01,<span style="color: #000000;">34</span> sec,OK,Avg:<span style="color: #000000;">34.00</span>,StdDev:0,OK,0,0
<span style="color: #000000;">1</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:06:<span style="color: #000000;">20</span>,<span style="color: #000000;">19</span> sec,OK,Avg:<span style="color: #000000;">26.50</span>,StdDev:<span style="color: #000000;">10.61</span>,OK,0,0
<span style="color: #000000;">2</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:06:<span style="color: #000000;">39</span>,<span style="color: #000000;">19</span> sec,OK,Avg:<span style="color: #000000;">19.00</span>,StdDev:<span style="color: #000000;">0.00</span>,OK,0,0
<span style="color: #000000;">3</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:06:<span style="color: #000000;">58</span>,<span style="color: #000000;">18</span> sec,OK,Avg:<span style="color: #000000;">18.67</span>,StdDev:<span style="color: #000000;">0.58</span>,OK,0,0
<span style="color: #000000;">4</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:07:<span style="color: #000000;">17</span>,<span style="color: #000000;">18</span> sec,OK,Avg:<span style="color: #000000;">18.50</span>,StdDev:<span style="color: #000000;">0.58</span>,OK,0,0
<span style="color: #000000;">5</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:07:<span style="color: #000000;">36</span>,<span style="color: #000000;">19</span> sec,OK,Avg:<span style="color: #000000;">18.60</span>,StdDev:<span style="color: #000000;">0.55</span>,OK,0,0
<span style="color: #000000;">6</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:07:<span style="color: #000000;">55</span>,<span style="color: #000000;">18</span> sec,OK,Avg:<span style="color: #000000;">18.50</span>,StdDev:<span style="color: #000000;">0.55</span>,OK,0,0
<span style="color: #000000;">7</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:08:<span style="color: #000000;">14</span>,<span style="color: #000000;">18</span> sec,OK,Avg:<span style="color: #000000;">18.43</span>,StdDev:<span style="color: #000000;">0.53</span>,OK,0,0
<span style="color: #000000;">8</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:08:<span style="color: #000000;">38</span>,<span style="color: #000000;">24</span> sec,OK,Avg:<span style="color: #000000;">19.12</span>,StdDev:<span style="color: #000000;">2.03</span>,SLOW,<span style="color: #000000;">10</span>,0
<span style="color: #000000;">9</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:09:<span style="color: #000000;">12</span>,<span style="color: #000000;">24</span> sec,OK,Avg:<span style="color: #000000;">19.67</span>,StdDev:<span style="color: #000000;">2.50</span>,OK,<span style="color: #000000;">9</span>,0