TeamSpeak 3 PHP Framework  1.1.12
libraries/TeamSpeak3/Helper/Profiler.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /**
00004  * @file
00005  * TeamSpeak 3 PHP Framework
00006  *
00007  * $Id: Profiler.php 2/18/2012 12:42:46 scp@orilla $
00008  *
00009  * This program is free software: you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation, either version 3 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00021  *
00022  * @package   TeamSpeak3
00023  * @version   1.1.12
00024  * @author    Sven 'ScP' Paulsen
00025  * @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
00026  */
00027 
00028 /**
00029  * @class TeamSpeak3_Helper_Profiler
00030  * @brief Helper class for profiler handling.
00031  */
00032 class TeamSpeak3_Helper_Profiler
00033 {
00034   /**
00035    * Stores various timers for code profiling.
00036    *
00037    * @var array
00038    */
00039   protected static $timers = array();
00040 
00041   /**
00042    * Inits a timer.
00043    *
00044    * @param  string $name
00045    * @return void
00046    */
00047   public static function init($name = "default")
00048   {
00049     self::$timers[$name] = new TeamSpeak3_Helper_Profiler_Timer($name);
00050   }
00051 
00052   /**
00053    * Starts a timer.
00054    *
00055    * @param  string $name
00056    * @return void
00057    */
00058   public static function start($name = "default")
00059   {
00060     if(array_key_exists($name, self::$timers))
00061     {
00062       self::$timers[$name]->start();
00063     }
00064     else
00065     {
00066       self::$timers[$name] = new TeamSpeak3_Helper_Profiler_Timer($name);
00067     }
00068   }
00069 
00070   /**
00071    * Stops a timer.
00072    *
00073    * @param  string $name
00074    * @return void
00075    */
00076   public static function stop($name = "default")
00077   {
00078     if(!array_key_exists($name, self::$timers))
00079     {
00080       self::init($name);
00081     }
00082 
00083     self::$timers[$name]->stop();
00084   }
00085 
00086   /**
00087    * Returns a timer.
00088    *
00089    * @param  string $name
00090    * @return TeamSpeak3_Helper_Profiler_Timer
00091    */
00092   public static function get($name = "default")
00093   {
00094     if(!array_key_exists($name, self::$timers))
00095     {
00096       self::init($name);
00097     }
00098 
00099     return self::$timers[$name];
00100   }
00101 }
 All Classes Files Functions Variables