Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Timer.php « modules - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 58543135161732edb30006e1d57f43c07ae0d4a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
class Piwik_Timer
{
    private $m_Start;

    public function __construct()
    {
        $this->m_Start = 0.0;
        $this->init();
    }

    private function getMicrotime()
    {
        list($micro_seconds, $seconds) = explode(" ", microtime());
        return ((float)$micro_seconds + (float)$seconds);
    }

    public function init()
    {
        $this->m_Start = $this->getMicrotime();
    }

    public function getTime($decimals = 2)
    {
        return number_format($this->getMicrotime() - $this->m_Start, $decimals, '.', '');
    }
    public function getTimeMs($decimals = 2)
    {
        return number_format(1000*($this->getMicrotime() - $this->m_Start), $decimals, '.', '');
    }
}
?>