jdump
jdump copied to clipboard
Two functions to start and stop / display a timer
I have created a timer feature for jdump. I have used the userstate to store the timer values to use the timer for more than one request (e.g. a number of AJAX calls)
/**
- Start a timer for JDump
- @param $name Unique Timer name - used to identify the timer
- @param string $message Additional message
- @return void */ function dumpStartTimer($name,$message="") { if($name) { // The UserState is used to create timers that work for more than one request - e.g. AJAX-loops $mainframe =& JFactory::getApplication(); $option = JRequest::getCmd('option'); $timernodes = $mainframe->getUserState( 'dumptimer.nodes' ); // append the node to the array $timernodes[] = array('T_Name'=>$name,'T_Message'=>$message,'T_Start'=>microtime(true)); // set the userstate to the new array $mainframe->setUserState( 'dumptimer.nodes', $timernodes ); } }
/**
- @param $name Unique Timer name as defined in StartTimer
- @param int $round Number of decimals to display for the duration
- @param bool $linebreaks if TRUE the message string contains linebreaks
- @return
*/
function dumpStopTimer($name,$round=5,$keepactive=FALSE,$linebreaks=false) {
if($name) {
$lbr=$linebreaks ? '
' : ' '; $stoptime=microtime(true);
It looks like the code is cut off. Can you post it again some other way, either as a pull request or as a Gist https://gist.github.com/ ?