Determine the throttle execution time, available to the public
@return integer   microseconds
512468
public function throttle()
    {
        if ((time() - $this->lastCpuCheck) >= $this->cpuCheckFrequency) {
            $load = sys_getloadavg();
            
            if ($load[0]/$this->cpuCount >= $this->cpuTarget) {
                $this->pause += $this->throttleSensitivity;
                $this->controller->notify('Daemon throttling down');
            } else {
                $this->pause -= $this->throttleSensitivity;
                $this->controller->notify('Daemon throttling up');
            }

            $this->lastCpuCheck = time();
        }

        // Never allow pause to dip below 1 microsecond
        if ($this->pause < 1) {
            $this->pause = 1;
        }

        return $this->pause;
    }
916258
public function getTotalExecutionTime()
    {
        return array_reduce(iterator_to_array($this->getCommands()), function ($time, $value) {
            $time += $value['executionTime'];

            return $time;
        });
    }
63898
public function getReadingSpeed()
    {
        $dur = $this->getDuration();
        $dur = ($dur <= 500) ? 501 : $dur;

        return ($this->strlen() * 1000) / ($dur - 500);
    }
965467
public function getDuration()
    {
        if (!isset($this->data['events']['__section__'])) {
            return 0;
        }

        $lastEvent = $this->data['events']['__section__'];

        return $lastEvent->getOrigin() + $lastEvent->getDuration() - $this->getStartTime();
    }
1246338
public function speed() {
		static $tick, $iteration = 0, $speed = 0;

		if (!$this->_start) {
			return 0;
		} else if (!$tick) {
			$tick = $this->_start;
		}

		$now = microtime(true);
		$span = $now - $tick;
		if ($span > 1) {
			$iteration++;
			$tick = $now;
			$speed = ($this->_current / $iteration) / $span;
		}

		return $speed;
	}
59287
public function getTimeSleepUntil()
    {
        if ($this->delay == 0) {
            return 0;
        }
        $query = $this->pdo->prepare(<<<SQL
SELECT
  delayUntil,
  UNIX_TIMESTAMP()
FROM robotstxt__delay0
WHERE base = :base AND userAgent = :userAgent;
SQL
        );
        $query->bindValue('base', $this->base, \PDO::PARAM_STR);
        $query->bindValue('userAgent', $this->userAgent, \PDO::PARAM_STR);
        $query->execute();
        $this->increment();
        if ($query->rowCount() > 0) {
            $row = $query->fetch(\PDO::FETCH_ASSOC);
            $this->clockSyncCheck($row['UNIX_TIMESTAMP()'], self::OUT_OF_SYNC_TIME_LIMIT);
            return $row['delayUntil'] / 1000000;
        }
        return 0;
    }
337727
protected function getClientTimeout()
    {
        $ext = $this->getServiceManager()->get(common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('tao');
        $config = $ext->getConfig('js');
        if($config !== null && isset($config['timeout'])){
            return (int)$config['timeout'];
        }
        return 30;
    }
990246
public function responseDuration(): ?float
    {
        $responseTime = $this->call->responseTime();

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

        return $responseTime - $this->call->time();
    }
1344706
protected function _callTimeHandlers()
    {
        foreach ($this->_timehandler as &$handlerinfo) {
            $microtimestamp = microtime(true);
            if ($microtimestamp >= $handlerinfo['lastmicrotimestamp']
                + ($handlerinfo['interval'] / 1000.0)
            ) {
                $callback = $handlerinfo['callback'];
                $handlerinfo['lastmicrotimestamp'] = $microtimestamp;

                $cbstring = (is_array($callback))
                    ? (is_object($callback[0])
                        ? get_class($callback[0])
                        : $callback[0]
                      ) . '->' . $callback[1]
                    : '(anonymous function)';

                if (is_callable($callback)) {
                    $this->log(SMARTIRC_DEBUG_TIMEHANDLER, 'DEBUG_TIMEHANDLER: calling "'.$cbstring.'"',
                        __FILE__, __LINE__
                    );
                    call_user_func($callback, $this);
                } else {
                    $this->log(SMARTIRC_DEBUG_TIMEHANDLER,
                        'DEBUG_TIMEHANDLER: callback is invalid! "'.$cbstring.'"',
                        __FILE__, __LINE__
                    );
                }
            }
        }
    }
776804
public function getTotalRedirectionTime()
    {
        return array_reduce(iterator_to_array($this->getCommands()), function ($time, $value) {
            $time += $value['curl']['redirectTime'];

            return $time;
        });
    }
1297956
static public function get_time() {
        // By David Maciel (jdmaciel@gmail.com)
        list($microsecond, $second) = explode(" ", \microtime());
        // remove '0.' from the beginning and trailing zeros(2) from the end
        $microsecond = substr($microsecond, 2, -2);
        return (int) $second . $microsecond;
    }
510087
public static function get_microtime() {
        list($tps_usec, $tps_sec) = explode(' ', microtime());
        return (float) $tps_usec + (float) $tps_sec;
    }
821515
protected function getTimeLimit()
    {
        $timeLimit = self::DEFAULT_TIME_LIMIT;
        if($this->hasOption(self::TIME_LIMIT_OPT)){
            $timeLimit = (int)$this->getOption(self::TIME_LIMIT_OPT);
        }
        return $timeLimit;
    }
995535
public function getTotalSeconds()
	{
		$dt = new \DateTimeImmutable();
		$seconds = $dt->getTimestamp();
		$result = new DecimalValue( $dt->add( $this->Value )->getTimestamp() - $seconds );
		$result = $result->Add( ( $this->Value->invert ? "-" : "" ) . "0.{$this->Value->microseconds}" );
		if ( $this->Value->invert )
		{
			// $result = $result->Mul( -1 );
		}
		return $result;
	}
51950
function throttle(f, delay) {
  var timeoutId;
  var previous = 0;

  return function throttleExecute_() {
    var args = arguments;
    var now = +(new Date());
    var remaining = delay - (now - previous);

    if (remaining <= 0) {
      clearTimeout(timeoutId);
      timeoutId = null;
      previous = now;

      f.apply(null, args);
    } else if (!timeoutId) {
      timeoutId = setTimeout(function() {
        previous = +(new Date());
        timeoutId = null;

        f.apply(null, args);
      }, remaining);
    }
  };
}
693117
public function getElapsedInMilliseconds() : float
    {
        if ($this->startedOn === null) {
            throw new NotStartedException();
        }

        return ($this->stoppedOn === null) ?
            $this->toMilli(microtime(true) - $this->startedOn) :
            $this->getDurationInMilliseconds();
    }
256454
public static function getRequestsRemaining()
    {
        $limit = self::connection()->getHeader('X-Rate-Limit-Requests-Left');

        if (!$limit) {
            $result = self::getTime();

            if (!$result) {
                return false;
            }

            $limit = self::connection()->getHeader('X-Rate-Limit-Requests-Left');
        }

        return (int)$limit;
    }