Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Saturday, April 20, 2024

Diff for phpMyEdit/Attic/timer.class between version 1.2 and 1.3

version 1.2, 2002/08/16 21:54:38 version 1.3, 2002/09/25 18:06:20
Line 1 
Line 1 
 <?php  <?php
 /*  /*
    This is a generic timer class.     This is a generic timer class.
   
    version 0.1 - 18-Jun-01     version 0.1 - 18-Jun-01
   
    Written by Jim Kraai (JimKraai@Polytopic.com)     Written by Jim Kraai (JimKraai@Polytopic.com)
   
    $Id$     $Id$
  */   */
   
 class timerClass {  class timerClass
   {
         var $startTime;          var $startTime;
         var $started;          var $started;
   
         function timerClass($start=true) {          function timerClass($start=true) {
                 $this->started = false;                  $this->started = false;
                 if ($start)                  if ($start)
                         $this->start();                          $this->start();
         }          }
   
         function start() {          function start() {
                 $startMtime = explode(' ',microtime());                  $startMtime = explode(' ',microtime());
                 $this->startTime = (double)($startMtime[0])+(double)($startMtime[1]);                  $this->startTime = (double)($startMtime[0])+(double)($startMtime[1]);
                 $this->started = true;                  $this->started = true;
         }          }
   
         function end($iterations=1) {          function end($iterations=1) {
                 // get the time, check whether the timer was started later                  // get the time, check whether the timer was started later
                 $endMtime = explode(' ',microtime());                  $endMtime = explode(' ',microtime());
                 if ($this->started) {                  if ($this->started) {
                         $endTime = (double)($endMtime[0])+(double)($endMtime[1]);                          $endTime = (double)($endMtime[0])+(double)($endMtime[1]);
                         $dur = $endTime - $this->startTime;                          $dur = $endTime - $this->startTime;
                         $avg = 1000*$dur/$iterations;                          $avg = 1000*$dur/$iterations;
                         $avg = round(1000*$avg)/1000;                          $avg = round(1000*$avg)/1000;
                         return "$avg milliseconds";                          return "$avg milliseconds";
                 } else {                  } else {
                         return "timer not started";                          return "timer not started";
                 }                  }
         }          }
   
 }  }
 ?>  
   ?>

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top