You are here

class Kint_Parsers_Microtime in Devel 8.2

Same name and namespace in other branches
  1. 8 kint/kint/parsers/custom/microtime.php \Kint_Parsers_Microtime

Hierarchy

Expanded class hierarchy of Kint_Parsers_Microtime

File

kint/kint/parsers/custom/microtime.php, line 3

View source
class Kint_Parsers_Microtime extends kintParser {
  private static $_times = array();
  private static $_laps = array();
  protected function _parse(&$variable) {
    if (!is_string($variable) || !preg_match('[0\\.[0-9]{8} [0-9]{10}]', $variable)) {
      return false;
    }
    list($usec, $sec) = explode(" ", $variable);
    $time = (double) $usec + (double) $sec;
    if (KINT_PHP53) {
      $size = memory_get_usage(true);
    }

    # '@' is used to prevent the dreaded timezone not set error
    $this->value = @date('Y-m-d H:i:s', $sec) . '.' . substr($usec, 2, 4);
    $numberOfCalls = count(self::$_times);
    if ($numberOfCalls > 0) {

      # meh, faster than count($times) > 1
      $lap = $time - end(self::$_times);
      self::$_laps[] = $lap;
      $this->value .= "\n<b>SINCE LAST CALL:</b> <b class=\"kint-microtime\">" . round($lap, 4) . '</b>s.';
      if ($numberOfCalls > 1) {
        $this->value .= "\n<b>SINCE START:</b> " . round($time - self::$_times[0], 4) . 's.';
        $this->value .= "\n<b>AVERAGE DURATION:</b> " . round(array_sum(self::$_laps) / $numberOfCalls, 4) . 's.';
      }
    }
    $unit = array(
      'B',
      'KB',
      'MB',
      'GB',
      'TB',
    );
    if (KINT_PHP53) {
      $this->value .= "\n<b>MEMORY USAGE:</b> " . $size . " bytes (" . round($size / pow(1024, $i = floor(log($size, 1024))), 3) . ' ' . $unit[$i] . ")";
    }
    self::$_times[] = $time;
    $this->type = 'Stats';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
kintParser::$_customDataTypes private static property
kintParser::$_dealingWithGlobals private static property
kintParser::$_level private static property
kintParser::$_marker private static property
kintParser::$_objectParsers private static property
kintParser::$_objects private static property
kintParser::$_placeFullStringInValue private static property
kintParser::$_skipAlternatives private static property
kintParser::escape public static function
kintParser::factory final public static function * the only public entry point to return a parsed representation of a variable * * @static * *
kintParser::reset public static function
kintParser::_checkDepth private static function
kintParser::_decorateCell private static function
kintParser::_init private static function
kintParser::_isArrayTabular private static function
kintParser::_parse_array private static function
kintParser::_parse_boolean private static function
kintParser::_parse_double private static function
kintParser::_parse_integer private static function
kintParser::_parse_null private static function
kintParser::_parse_object private static function
kintParser::_parse_resource private static function
kintParser::_parse_string private static function
kintParser::_parse_unknown private static function
kintVariableData::$access public property @var string
kintVariableData::$extendedValue public property * * the array is a separate possible representation of the dumped var
kintVariableData::$name public property @var string
kintVariableData::$operator public property @var string
kintVariableData::$size public property @var int
kintVariableData::$type public property @var string
kintVariableData::$value public property @var string inline value
kintVariableData::$_alternatives public property @var kintVariableData[] array of alternative representations for same variable, don't use in custom parsers
kintVariableData::$_supportedCharsets private static property
kintVariableData::_detectEncoding protected static function
kintVariableData::_isSequential protected static function * returns whether the array: * 1) is numeric and * 2) in sequence starting from zero * *
kintVariableData::_strlen protected static function
kintVariableData::_substr protected static function
Kint_Parsers_Microtime::$_laps private static property
Kint_Parsers_Microtime::$_times private static property
Kint_Parsers_Microtime::_parse protected function * main and usually single method a custom parser must implement * * Overrides kintParser::_parse