File: 1.15.1a/server/base/timer.inc.php (View as HTML)

  1: <?php // timer.inc.php
  2: /* -------------------------------------------------------------
  3: This file is part of FreeNATS
  4: 
  5: FreeNATS is (C) Copyright 2008 PurplePixie Systems
  6: 
  7: FreeNATS is free software: you can redistribute it and/or modify
  8: it under the terms of the GNU General Public License as published by
  9: the Free Software Foundation, either version 3 of the License, or
 10: (at your option) any later version.
 11: 
 12: FreeNATS is distributed in the hope that it will be useful,
 13: but WITHOUT ANY WARRANTY; without even the implied warranty of
 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15: GNU General Public License for more details.
 16: 
 17: You should have received a copy of the GNU General Public License
 18: along with FreeNATS.  If not, see www.gnu.org/licenses
 19: 
 20: For more information see www.purplepixie.org/freenats
 21: -------------------------------------------------------------- */
 22: 
 23: class TFNTimer
 24: {
 25: var $StartSecs;
 26: var $StartMSecs;
 27: var $FinishSecs;
 28: var $FinishMSecs;
 29: var $Elapsed;
 30: var $SafeElapsed;
 31: 
 32: function Start()
 33: 	{
 34: 	$timeString=microtime();  // 0.000000 0000000
 35: 	$timeArray=explode(" ",$timeString);
 36: 	$this->StartSecs=$timeArray[1];
 37: 	$this->StartMSecs=$timeArray[0];
 38: 	}
 39: 	
 40: function Stop()
 41: 	{
 42: 	$timeString=microtime();
 43: 	$timeArray=explode(" ",$timeString);
 44: 	$this->FinishSecs=$timeArray[1];
 45: 	$this->FinishMSecs=$timeArray[0];
 46: 	
 47: 	$elapSecs=$this->FinishSecs-$this->StartSecs;
 48: 	//$newFinish=$elapSecs.substr($this->FinishMSecs,1,128);
 49: 	$newFinish=$elapSecs+$this->FinishMSecs;
 50: 	
 51: 	$this->Elapsed=$newFinish-$this->StartMSecs;
 52: 	$this->SafeElapsed=round($this->Elapsed,3);
 53: 	if ($this->SafeElapsed<=0) $this->SafeElapsed="0.0001";
 54: 	
 55: 	return $this->SafeElapsed;
 56: 	}
 57: }
 58: 
 59: ?>