<?php
//--------------------------------------------------------------------
// PHP TimeCheck Class
//
// Copyright Jeff Redding, 2003, All Rights Reserved.
//
// This module provides a class to perform simple elapsed time
// indications.
//
// Version: $Id: TimeCheck.inc,v 1.2 2003/08/04 18:00:37 jwr Exp $
//
//--------------------------------------------------------------------
class TimeCheck
{
var $beginTime = 0;
var $beginString = "";
var $markArray = array();
//--------------------------------------------------------------------
// Constructor for TimeCheck.
//--------------------------------------------------------------------
function TimeCheck()
{
}
//--------------------------------------------------------------------
// Private function for getting microseconds
//--------------------------------------------------------------------
function _getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
//--------------------------------------------------------------------
// Mark the begin time. The elapsed time for marks are calculated
// from this point.
//--------------------------------------------------------------------
function begin($outstring)
{
$this->beginTime = $this->_getmicrotime();
unset($this->markArray);
$this->beginString = $outstring;
}
//--------------------------------------------------------------------
// Add a mark string, and value
//--------------------------------------------------------------------
function mark($outstring)
{
$this->markArray[$outstring] = $this->_getmicrotime();
}
//--------------------------------------------------------------------
// Output all the mark strings, their time stamps, elapsed individual
// and elapsed overall times.
//--------------------------------------------------------------------
function displayMarks()
{
$bt = sprintf('%.16f', $time_end - $time_start);
echo $this->beginString.": start time -> ".date("H:i:s", $this->beginTime)."<BR>";
echo "<ul>";
$last_time = $this->beginTime;
foreach($this->markArray as $index => $value)
{
$elapse = sprintf('%.4f', $value - $last_time);
$total = sprintf('%.4f', $value - $this->beginTime);
echo "<LI>".$index." --> ".date("H:i:s", $value).", ".$elapse." elapsed, ".$total." total<BR>";
$last_time = $value;
}
echo "</ul>";
}
} // End class
?>