TeamSpeak 3 PHP Framework
Modern use-at-will framework that provides individual components to manage TeamSpeak 3 Server instances
TeamSpeak3_Helper_Profiler_Timer Class Reference

Helper class providing profiler timers. More...

Public Member Functions

 __construct ($name)
 The TeamSpeak3_Helper_Profiler_Timer constructor. More...
 
 getMemUsage ($realmem=FALSE)
 Returns the amount of memory allocated to PHP in bytes. More...
 
 getRuntime ()
 Return the timer runtime. More...
 
 isRunning ()
 Returns TRUE if the timer is running. More...
 
 start ()
 Starts the timer. More...
 
 stop ()
 Stops the timer. More...
 

Detailed Description

Helper class providing profiler timers.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $name)

The TeamSpeak3_Helper_Profiler_Timer constructor.

Parameters
string$name
Returns
TeamSpeak3_Helper_Profiler_Timer
66  {
67  $this->name = (string) $name;
68 
69  $this->data["runtime"] = 0;
70  $this->data["realmem"] = 0;
71  $this->data["emalloc"] = 0;
72 
73  $this->start();
74  }
start()
Starts the timer.
Definition: Timer.php:81

Member Function Documentation

◆ getMemUsage()

getMemUsage (   $realmem = FALSE)

Returns the amount of memory allocated to PHP in bytes.

Parameters
boolean$realmem
Returns
integer
132  {
133  if($this->isRunning())
134  {
135  $this->stop();
136  $this->start();
137  }
138 
139  return ($realmem !== FALSE) ? $this->data["realmem"] : $this->data["emalloc"];
140  }
start()
Starts the timer.
Definition: Timer.php:81
isRunning()
Returns TRUE if the timer is running.
Definition: Timer.php:147
stop()
Stops the timer.
Definition: Timer.php:97

◆ getRuntime()

getRuntime ( )

Return the timer runtime.

Returns
mixed
115  {
116  if($this->isRunning())
117  {
118  $this->stop();
119  $this->start();
120  }
121 
122  return $this->data["runtime"];
123  }
start()
Starts the timer.
Definition: Timer.php:81
isRunning()
Returns TRUE if the timer is running.
Definition: Timer.php:147
stop()
Stops the timer.
Definition: Timer.php:97

◆ isRunning()

isRunning ( )

Returns TRUE if the timer is running.

Returns
boolean
148  {
149  return $this->running;
150  }

◆ start()

start ( )

Starts the timer.

Returns
void
82  {
83  if($this->isRunning()) return;
84 
85  $this->data["realmem_start"] = memory_get_usage(TRUE);
86  $this->data["emalloc_start"] = memory_get_usage();
87 
88  $this->started = microtime(TRUE);
89  $this->running = TRUE;
90  }
isRunning()
Returns TRUE if the timer is running.
Definition: Timer.php:147

◆ stop()

stop ( )

Stops the timer.

Returns
void
98  {
99  if(!$this->isRunning()) return;
100 
101  $this->data["runtime"] += microtime(TRUE) - $this->started;
102  $this->data["realmem"] += memory_get_usage(TRUE) - $this->data["realmem_start"];
103  $this->data["emalloc"] += memory_get_usage() - $this->data["emalloc_start"];
104 
105  $this->started = 0;
106  $this->running = FALSE;
107  }
isRunning()
Returns TRUE if the timer is running.
Definition: Timer.php:147

The documentation for this class was generated from the following file: