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

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'modules/Timer.php')
-rw-r--r--modules/Timer.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/modules/Timer.php b/modules/Timer.php
new file mode 100644
index 0000000000..5854313516
--- /dev/null
+++ b/modules/Timer.php
@@ -0,0 +1,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, '.', '');
+ }
+}
+?> \ No newline at end of file