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:
authormattpiwik <matthieu.aubry@gmail.com>2008-12-08 17:08:24 +0300
committermattpiwik <matthieu.aubry@gmail.com>2008-12-08 17:08:24 +0300
commit93ac4b09d9f0b2deec4ea0fa56d8fe4b5bc08437 (patch)
tree00a6cb5a31bdd30706ae5e7959d78993308d9181 /core/Timer.php
parent40cf751bf1d592900feb3684c567fbe148d9e97f (diff)
- cleaning the API/ code
- deleting class Api_Apiable concept not used anymore git-svn-id: http://dev.piwik.org/svn/trunk@826 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'core/Timer.php')
-rw-r--r--core/Timer.php34
1 files changed, 23 insertions, 11 deletions
diff --git a/core/Timer.php b/core/Timer.php
index 8e71b41ba5..783dcff6ea 100644
--- a/core/Timer.php
+++ b/core/Timer.php
@@ -15,36 +15,48 @@
*/
class Piwik_Timer
{
- private $m_Start;
+ private $timerStart;
+ private $memoryStart;
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();
+ $this->timerStart = $this->getMicrotime();
+ $this->memoryStart = $this->getMemoryUsage();
}
public function getTime($decimals = 2)
{
- return number_format($this->getMicrotime() - $this->m_Start, $decimals, '.', '');
+ return number_format($this->getMicrotime() - $this->timerStart, $decimals, '.', '');
}
+
public function getTimeMs($decimals = 2)
{
- return number_format(1000*($this->getMicrotime() - $this->m_Start), $decimals, '.', '');
+ return number_format(1000*($this->getMicrotime() - $this->timerStart), $decimals, '.', '');
}
+ public function getMemoryLeak()
+ {
+ return "Memory delta: ".Piwik::getPrettySizeFromBytes($this->getMemoryUsage() - $this->memoryStart);
+ }
+
public function __toString()
{
return "Time elapsed: ". $this->getTime() ."s";
}
+
+ private function getMicrotime()
+ {
+ list($micro_seconds, $seconds) = explode(" ", microtime());
+ return ((float)$micro_seconds + (float)$seconds);
+ }
+
+ private function getMemoryUsage()
+ {
+ return memory_get_usage();
+ }
}