jdump icon indicating copy to clipboard operation
jdump copied to clipboard

Two functions to start and stop / display a timer

Open tkahl opened this issue 13 years ago • 1 comments

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);

tkahl avatar Mar 31 '11 05:03 tkahl

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/ ?

mathiasverraes avatar Mar 31 '11 07:03 mathiasverraes