Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, March 29, 2024

File: [Platon] / phpMyEdit / Attic / timer.class (download)

Revision 1.4, Thu Oct 17 21:06:46 2002 UTC (21 years, 5 months ago) by nepto


Changes since 1.3: +1 -1 lines

[17/10/2002] release 5.1 (official)
- added support for ['values2'] which can be used in addition to table lookup
  done by ['values']['table'] and similar options
- fixed save/change/delete bug, which updates bad fields not according to
  performed action
- added copyright headers into PHP files
- file doc/COPYING file added into distribution

<?php
/*
   This is a generic timer class.

   version 0.1 - 18-Jun-01

   Written by Jim Kraai (JimKraai@Polytopic.com)

   $Platon: timer.class,v 1.3 2002/09/25 18:06:20 nepto Exp $
 */

class timerClass
{
    var $startTime;
    var $started;

    function timerClass($start=true) {
        $this->started = false;
        if ($start)
            $this->start();
    }

    function start() {
        $startMtime = explode(' ',microtime());
        $this->startTime = (double)($startMtime[0])+(double)($startMtime[1]);
        $this->started = true;
    }

    function end($iterations=1) {
        // get the time, check whether the timer was started later
        $endMtime = explode(' ',microtime());
        if ($this->started) {
            $endTime = (double)($endMtime[0])+(double)($endMtime[1]);
            $dur = $endTime - $this->startTime;
            $avg = 1000*$dur/$iterations;
            $avg = round(1000*$avg)/1000;
            return "$avg milliseconds";
        } else {
            return "timer not started";
        }
    }

}

?>

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