﻿class Stopwatch {
    public function __construct() {
        $this->start0 = microtime(TRUE);
        $this->end0 = 0;
    }
    private $start0;
    private $end0;
    
    public function Start() {
        $this->end0 = 0;
    }
    public function Stop() {
        $this->end0 = microtime(TRUE);
    }
    public function Reset() {
        $this->start0 = microtime(TRUE);
        $this->end0 = 0;
    }
    public function IsRunning() {
        return $this->end0 === 0;
    }
    public function GetElapsedMilliseconds() {
        $end = $this->end0;
        if($end == 0) $end = microtime(TRUE);
        $res = $end - $this->start0;
        return $res * 1000;
    }
    
}