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:
authorsgiehl <stefan@piwik.org>2013-08-02 21:52:14 +0400
committersgiehl <stefan@piwik.org>2013-08-02 21:52:14 +0400
commitbbb9c0e10868fdf96e1c53f8f7dd71a14e0abd53 (patch)
tree80b00ddcb5bca16f6762e9ca088e76aeead61ebb /core/Timer.php
parent54e0234ab1a1865d1d2aebd1aa59dc667b9f29b5 (diff)
fixed some doc blocks/namespaces
Diffstat (limited to 'core/Timer.php')
-rw-r--r--core/Timer.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/core/Timer.php b/core/Timer.php
index d3f1e29d79..c1d17a8020 100644
--- a/core/Timer.php
+++ b/core/Timer.php
@@ -21,43 +21,71 @@ class Timer
private $timerStart;
private $memoryStart;
+ /**
+ * @return \Piwik\Timer
+ */
public function __construct()
{
$this->init();
}
+ /**
+ * @return void
+ */
public function init()
{
$this->timerStart = $this->getMicrotime();
$this->memoryStart = $this->getMemoryUsage();
}
+ /**
+ * @param int $decimals
+ * @return string
+ */
public function getTime($decimals = 3)
{
return number_format($this->getMicrotime() - $this->timerStart, $decimals, '.', '');
}
+ /**
+ * @param int $decimals
+ * @return string
+ */
public function getTimeMs($decimals = 3)
{
return number_format(1000 * ($this->getMicrotime() - $this->timerStart), $decimals, '.', '');
}
+ /**
+ * @return string
+ */
public function getMemoryLeak()
{
return "Memory delta: " . Piwik::getPrettySizeFromBytes($this->getMemoryUsage() - $this->memoryStart);
}
+ /**
+ * @return string
+ */
public function __toString()
{
return "Time elapsed: " . $this->getTime() . "s";
}
+ /**
+ * @return float
+ */
private function getMicrotime()
{
list($micro_seconds, $seconds) = explode(" ", microtime());
return ((float)$micro_seconds + (float)$seconds);
}
+ /**
+ * Returns current memory usage, if available
+ *
+ * @return int
+ */
private function getMemoryUsage()
{
if (function_exists('memory_get_usage')) {