Get the current duration

@param integer $precision
@return string|float
334777
public function getDuration(int $precision = -1)
    {
        //var_dump($this->duration);
        $duration = $this->duration ?? microtime(true) - $this->startTime;
        return $this->fmtDuration($duration, $precision);
    }
879142
public function getIsDecimalEven( $precision = false )
	{
		if ( ! $this->getIsDecimal() ) {
			return false;
		}

		if ( $precision === false ) $precision = $this->scale( $this->_value );
		if ( $precision < 0 ) $precision = $precision = 0;

		$decimalPart = $this->getDecimalPart();
		if ( $precision >= strlen( $decimalPart ) ) return false;

		// Get the portion of the decimal part affected by the scale value
		$decimalPart = substr( $decimalPart, $precision );
		return $decimalPart[0] % 2 === 0;
	}
1319238
public function getDuration() : ?string 
    {
        if ( ! $this->hasDuration()) {
            $this->setDuration($this->getDefaultDuration());
        }
        return $this->duration;
    }
139373
public static function ceil($num, int $precision=0) {
		ref\format::ceil($num, $precision);
		return $num;
	}
141432
protected function _getEid($elapsed, $precision = 0.1)
    {
        $id = '';
        for ($level = 0; $level < 3; $level++) {
            /** @noinspection PowerOperatorCanBeUsedInspection */
            $current = $precision * pow(10, $level);
            if ($current >= 10) {
                break;
            }
            $count = min($elapsed / $current, 10);
            for ($i = 1; $i < $count; $i++) {
                $id .= 't' . (($current >= 1) ? $current * $i : substr(1 / $current, 1) . $i);
            }
        }

        return $id;
    }
899878
public function currentInterval($format = null)
    {

        // Relative time formatting
        $abbreviated = [
            'pluraling' => false,
            'spacing' => false,
            'labels' => ['now', 's', 'm', 'h', 'd', 'm', 'y'],
        ];

        // Figure stuff out
        if ($this->isRunning()) {
            $interval = $this->WORKER_SLEEP_SECS;
        } else {
            $check = Cache::get($this->HEARTBEAT_CRON_KEY);
            if (empty($check)) {
                $interval = 'uncertain';
            } else {
                $interval = $check->interval;
            }
        }

        // Format it
        if (!is_numeric($interval)) {
            return $interval;
        }
        switch ($format) {
            case 'raw':
                return $interval;

            case 'abbreviated':
                return Library\Utils\Text::timeElapsed(time() - $interval, $abbreviated);

            default:
                return Library\Utils\Text::timeElapsed(time() - $interval);
        }
    }
600748
public static function formatDuration($duration, $precision = 3)
    {
        if ($duration < 1) {
            $duration *= 1000;
            $unit = 'ms';
        } else {
            $unit = 's ';
        }

        return self::toPrecision($duration, $precision) . $unit;
    }
990246
public function responseDuration(): ?float
    {
        $responseTime = $this->call->responseTime();

        if (null === $responseTime) {
            return null;
        }

        return $responseTime - $this->call->time();
    }
705080
public function getPrettyNumber($value, $precision = 0)
    {
        if ($this->decimalPoint === null) {
            $locale = localeconv();

            $this->decimalPoint = $locale['decimal_point'];
            $this->thousandsSeparator = $locale['thousands_sep'];
        }

        return number_format($value, $precision, $this->decimalPoint, $this->thousandsSeparator);
    }
1229085
public function formatDecimal( int $precision = 8 ) : string
   {

      $returnValue = '';

      if ( ! $this->isValid() )
      {
         return $returnValue;
      }

      $returnValue .= $this->Latitude->formatDecimal( $precision )
                      .  ', '
                      .  $this->Longitude->formatDecimal( $precision );

      return $returnValue;

   }
1358994
public function getMinutes($round_method = null)
    {
        $result = $this->interval / (1000 * 60);

        return $this->round($result, $round_method);
    }
1136516
public function toDecimal($value, int $precision = 12): float
    {
        if (is_numeric($value) === false) {
            return 0.0;
        }

        return round((float) $value, $precision);
    }
376020
protected function getFractionalPrecision($value)
    {
        /*
         * This is a bit hacky (and probably slow). We get the string
         * representation and then count the number of digits after the decimal
         * separator. This may or may not be faster than the equivalent
         * IEEE-754 decomposition (written in PHP). The string-based code has
         * not been profiled against the equivalent IEEE-754 code.
         */

        $value = (float) $value;

        // get current locale
        $locale = self::get();

        $precision = 0;
        $lc = $locale->getLocaleInfo();
        $str_value = (string) $value;

        $e_pos = mb_stripos($str_value, 'E-');
        if ($e_pos !== false) {
            $precision += (int) mb_substr($str_value, $e_pos + 2);
            $str_value = mb_substr($str_value, 0, $e_pos);
        }

        $decimal_pos = mb_strpos($str_value, $lc['decimal_point']);
        if ($decimal_pos !== false) {
            $precision +=
                mb_strlen($str_value) -
                $decimal_pos -
                mb_strlen($lc['decimal_point']);
        }

        return $precision;
    }
182916
public function timestamps($precision = 0)
    {
        $this->timestamp('created_at', $precision)->nullable();

        $this->timestamp('updated_at', $precision)->nullable();
    }
510087
public static function get_microtime() {
        list($tps_usec, $tps_sec) = explode(' ', microtime());
        return (float) $tps_usec + (float) $tps_sec;
    }
941956
protected function getMinutes($duration)
    {
        if ($duration instanceof DateTime) {
            $duration = (time()-$duration->getTimestamp()) / 60;
        }

        return (int) ($duration * 60) > 0 ? $duration : null;
    }
1017096
public function ceilf($value, $precision = null) {

        $precision        = isset($precision) ? (int)$precision : $this->config->get('price.default_precision');
        $precision_factor = $precision == 0 ? 1 : pow(10, $precision);
        $tmp              = $value * $precision_factor;
        $tmp2             = (string)$tmp;

        // Si la valeur actuelle a déjà la précision désirée.
        if (strpos($tmp2, '.') === false && strpos($tmp2, ',') === false) {
            return ($value);
        }
        if ($tmp2[strlen($tmp2) - 1] == 0) {
            return $value;
        }

        return ceil($tmp) / $precision_factor;
    }