You are here

function crumbs_benchmark in Crumbs, the Breadcrumbs suite 7

Same name and namespace in other branches
  1. 6.2 crumbs.module \crumbs_benchmark()

Measures time between two runs and displays it in a human-readable format.

Parameters

$label: String used to identify the measured time.

A string with the measurement, or NULL if the function was run for the: first time.

1 call to crumbs_benchmark()
crumbs_debug_page in admin/crumbs.debug.inc

File

./crumbs.module, line 541
Provides an API for building breadcrumbs.

Code

function crumbs_benchmark($label = NULL) {
  static $previous_time;
  $current_time = microtime(TRUE);
  if (isset($previous_time) && isset($label)) {
    $str = 'Duration: ' . number_format(1000 * ($current_time - $previous_time), 3) . ' ms for ' . $label;
  }
  $previous_time = $current_time;
  return isset($str) ? $str : NULL;
}