Marks the time.
If timer was not started starts the timer.
@param int|null $iterationNumber
@return self
165205
public function check(?int $iterationNumber = null): self
    {
        if ($this->isStopped()) {
            throw new \RuntimeException('Timer[' . $this->name . '] is already stopped.');
        }
        if ($this->isNotStarted()) {
            $this->start();
        } else {
            $this->mark($iterationNumber);
        }
        return $this;
    }
150072
public function retry(int $times = 1, int $timeout = 0): Call
    {
        \assert('$times >= 1 && $timeout >= 0');
        \assert('$this->current !== null');
        if ($this->current !== null) {
            $this->catchers[$this->current][] = function (...$args) use ($times, $timeout) {
                static $lTimes;
                if ($lTimes === null) {
                    $lTimes = $times;
                }
                // the first end() is already invoked
                $lTimes--;
                if ($lTimes > 0) {
                    usleep($timeout);
                    return $this->end(...$args);
                }
                return null;
            };
        }
        return $this;
    }
496070
public function setTimeout($timeout)
    {
        if (is_string($timeout) && ctype_digit($timeout)) {
            $timeout = (int) $timeout;
        } elseif (!is_int($timeout)) {
            throw new \RuntimeException('Unable to set timeout.');
        }
        $this->timeout = $timeout;

        return $this;
    }
914252
protected function setTimers()
    {
        if (!$this->exists('session.timer.start')) {
            $start = time();

            $this->set('session.timer.start', $start);
            $this->set('session.timer.last', $start);
            $this->set('session.timer.now', $start);
        }

        $this->set('session.timer.last', $this->get('session.timer.now'));
        $this->set('session.timer.now', time());

        return $this;
    }
797166
protected function setTimers()
	{
		if (!$this->has('session.timer.start'))
		{
			$start = time();

			$this->set('session.timer.start', $start);
			$this->set('session.timer.last', $start);
			$this->set('session.timer.now', $start);
		}

		$this->set('session.timer.last', $this->get('session.timer.now'));
		$this->set('session.timer.now', time());

		return true;
	}
242247
public function timerAction($string)
    {
        // Did we use this one before?
        if (isset(static::$counterCache[$string]) === true) {
            // Add another to the counter.
            ++static::$counterCache[$string];
            static::$timekeeping['[' . static::$counterCache[$string] . ']' . $string] = microtime(true);
        } else {
            // First time counter, set it to 1.
            static::$counterCache[$string] = 1;
            static::$timekeeping[$string] = microtime(true);
        }

        return $this;
    }
940043
protected function reset()
    {
        $this->status = null;
        $this->results = [];
        $this->currentDriver = null;
        $this->time['started_at'] = 0;
        $this->time['finished_at'] = 0;

        return $this;
    }
16621
public function setCurrentTime(): self
	{
		return $this->modifyClone()->setTime((int) date('H'), (int) date('i'), (int) date('s'));
	}
147274
public function changeReminders($reminderRepository, $reminderMappping = null)
    {
        $this->repositories['reminder'] = $reminderRepository;
        $this->mappings['reminder'] = $reminderMappping ?: $this->mappings['reminder'];

        return $this;
    }
898846
public function stopAfter(int $seconds): self
    {
        $seconds = 0 >= $seconds ? 1 : $seconds;

        /** @psalm-suppress MixedTypeCoercion Incorrect amphp types */
        Loop::delay(
            $seconds * 1000,
            function() use ($seconds): void
            {
                /** @var LoggerInterface $logger */
                $logger = $this->getKernelContainerService('service_bus.logger');

                $logger->info('The demon\'s lifetime has expired ({lifetime} seconds)', ['lifetime' => $seconds]);

                $this->entryPoint->stop();
            }
        );

        return $this;
    }
1103277
protected function _reset()
    {
        $tracker = $this->_getTracker();
        $this->_resetTracker($tracker);
        $iteration = $this->_createIterationFromTracker($tracker);

        return $iteration;
    }
66986
public function mark_inprogress($timestarted = null) {

        $timenow = time();

        // Set reaggregate flag
        $this->reaggregate = $timenow;

        if (!$this->timestarted) {

            if (!$timestarted) {
                $timestarted = $timenow;
            }

            $this->timestarted = $timestarted;
        }

        return $this->_save();
    }
1079445
protected function setStarted($time = null)
    {
        $this->started = $time ?: microtime(true);
        $this->setState(RunInterface::STATE_RUNNING);
    }
423943
public function markFraud($timestamp = null)
  {
    if(empty($this->_customerFid))
    {
      throw new \RuntimeException(
        "You cannot mark a customer as fraud before setting a customer fid"
      );
    }

    $ep = $this->_getEndpoint();
    $this->_processRequest(
      $ep->markFraud(MarkDatePayload::create($this->_customerFid, $timestamp))
    );
    return $this;
  }
1348688
public function timer($metric, $duration = null, array $tags = array(), $sampleRate = AbstractMetric::DEFAULT_SAMPLE_RATE)
    {
        return new Timer($this->prefix($metric), $duration, array_merge($this->defaultTags, $tags), $sampleRate);
    }
523866
public static function task($iterations, callable $callback)
    {
        set_time_limit(0);
        $memory   = \memory_get_usage();
        $time = 0;

        $e = null;

        try
        {
            set_time_limit(0);

            $iterator = 0;
            $memory   = \memory_get_usage();
            $time     = \microtime(true);

            while ($iterator < $iterations)
            {
                $callback($iterator++);
            }
        }
        catch (\Throwable $e)
        {
        }

        $stopTime       = \microtime(true);
        $stopMemory     = \memory_get_usage();
        $stopMemoryReal = \memory_get_usage(true);
        $stopMemoryPeak = \memory_get_peak_usage();

        return new BenchmarkResult(
            [
                'start'     => $time,
                'stop'      => $stopTime,
                'execution' => $stopTime - $time,
            ],
            [
                'usage'     => $stopMemory - $memory,
                'realUsage' => $stopMemoryReal,
                'peakUsage' => $stopMemoryPeak,
            ],
            $e
        );
    }
1214368
public function addTimer(Timer $timer)
  {
    if ( false === ($step=$this->currentStep()) ){
      throw new \Exception('No current step');
    }
    
    $step->setTimer($timer);
    return $this;
  }