Skip to content

Instantly share code, notes, and snippets.

@eftakhairul
Last active December 15, 2015 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eftakhairul/5202780 to your computer and use it in GitHub Desktop.
Save eftakhairul/5202780 to your computer and use it in GitHub Desktop.
Easy Debug
class Debug
{
private $debug = true;
private $start_time = 0;
/**
* prints debug message
* @param type $message
*/
public function debug($message)
{
if (!$this->debug)
return;
if ($this->start_time == 0) {
$duration = 0;
} else {
$duration = round((time() - $this->start_time));
}
echo '[DEBUG] ' . $message . ' ( Mem: ' . round(memory_get_usage() / 1048576, 2) . " MB, Time: $duration s )\n";
$this->start_time = time();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment