function fp_debug_current_time_millis

6.x misc.inc fp_debug_current_time_millis($debug_val = "", $show_current_time = true, $var = "")
7.x misc.inc fp_debug_current_time_millis($debug_val = "", $show_current_time = true, $var = "")
4.x misc.inc fp_debug_current_time_millis($debug_val = "", $show_current_time = true, $var = "")
5.x misc.inc fp_debug_current_time_millis($debug_val = "", $show_current_time = true, $var = "")

When called repeatedly, this function will display a message along with a milisecond count out to the side. Very useful for developers to time function calls or queries, to see how long they are taking.

For example: fp_debug_ct("starting query"); db_query(".........") // whatever fp_debug_ct("finished query");

On screen, that would display our messages, with time values, so we can see how many milliseconds it took to execute between calls of fp_debug_ct().

Parameters

String $debug_val: The message to display on screen.

boolean $show_current_time: Should we display the current time as well?

String $var: Optional. Include a variable name so you can have more than one timer running at the same time.

Return value

unknown

1 call to fp_debug_current_time_millis()

File

includes/misc.inc, line 3080
This file contains misc functions for FlightPath

Code

function fp_debug_current_time_millis($debug_val = "", $show_current_time = true, $var = "") 
 {
  // Display the current time in milliseconds, and, if available,
  // show how many milliseconds its been since the last time
  // this function was called.  This helps programmers tell how
  // long a particular function takes to run.  Just place a call
  // to this function before and after the function call.

  $rtn = "";

  $debug_string = $debug_val;
  if (is_array($debug_val) || is_object($debug_val)) {
    $debug_string = "<pre>" . print_r($debug_val, true) . "</pre>";
  }

  $last_time = @($GLOBALS ["current_time_millis" . $var]) * 1; //*1 forces numeric

  $cur_time = microtime(true) * 1000;

  $debug_string = "<span style='color:red;'>DEBUG:</span>
            <span style='color:green;'>$debug_string</span>";

  $rtn .= "<div style='background-color: white;'>$debug_string";

  if ($last_time > 1) 
   {
    $diff = round($cur_time - $last_time, 2);
    $rtn .= "<span style='color: blue;'> ($diff" . t("ms since last call") . "</span>";
  }
  else {
    // Start of clock...
    $rtn .= "<span style='color: blue;'> --- </span>";
  }

  $rtn .= "</div>";
  $GLOBALS ["current_time_millis" . $var] = $cur_time;
  $GLOBALS ["current_time_millis"] = $cur_time;

  return $rtn;
}