Get job duration.

@return bool|int time in seconds, or false
559015
public function getDuration()
    {
        $duration = false;
        if ($this->getExecutedAt() && ($this->getExecutedAt() != '0000-00-00 00:00:00')) {
            if ($this->getFinishedAt() && ($this->getFinishedAt() != '0000-00-00 00:00:00')) {
                $time = strtotime($this->getFinishedAt());
            } elseif ($this->getStatus() == Aoe_Scheduler_Model_Schedule::STATUS_RUNNING) {
                $time = time();
            } else {
                // Mage::throwException('No finish time found, but the job is not running');
                return false;
            }
            $duration = $time - strtotime($this->getExecutedAt());
        }
        return $duration;
    }
1304237
public function getTimeStamp()
    {
        if ($this->exists && !isset($this->timestamp)) {
            $this->timestamp = @filemtime($this->filepath);
        }
        return $this->timestamp;
    }
264336
private function get_time_duration_from_form_data(\stdClass $data) {
        if ($data->duration == 1) {
            return $data->timedurationuntil - $data->timestart;
        } else if ($data->duration == 2) {
            return $data->timedurationminutes * MINSECS;
        } else {
            return 0;
        }
    }
957080
public function getTotalElapsedTime() {
		$time = 0;
		
		foreach ($this->_profiles as $profile) {
			$time += $profile->getElapsedTime();
		}
		
		return $time;
	}
1191070
public function getIsExpired()
    {
        $expirationDuration = $this->getExpireDuration();
        if (empty($expirationDuration)) {
            return false;
        }

        return (time() >= ($this->createTimestamp + $expirationDuration));
    }
178686
public function getDuration()
    {
        $name = trim((string) $this->getParameter('name'));
        $fullPage = StringUtils::strToBool((string)$this->getParameter('FullPage'));
        if (empty($name))
            $name = 'default';

        if (in_array($name, explode(',', 'none,never,off,0,zero,no')))
            return 0;

        if (!array_key_exists($name, $this->durations))
            $name = 'default';

        $duration = abs((int)$this->durations[$name]);

        if (!$fullPage || $duration < 1)
            return $duration;

        // full page cache duration should be half the cache time
        return ceil($duration/2);
    }
1089439
public function timeout(): ?ObjectId
    {
        if (null === $this->current_job) {
            $this->logger->debug('reached worker timeout signal, no job is currently processing, ignore it', [
                'category' => get_class($this),
                'pm' => $this->process,
            ]);

            return null;
        }

        $this->logger->debug('received timeout signal, reschedule current processing job ['.$this->current_job['_id'].']', [
            'category' => get_class($this),
            'pm' => $this->process,
        ]);

        $this->updateJob($this->current_job, JobInterface::STATUS_TIMEOUT);

        $this->db->{$this->scheduler->getEventQueue()}->insertOne([
            'job' => $this->current_job['_id'],
            'worker' => $this->id,
            'status' => JobInterface::STATUS_TIMEOUT,
            'timestamp' => new UTCDateTime(),
        ]);

        $job = $this->current_job;

        if (0 !== $job['options']['retry']) {
            $this->logger->debug('failed job ['.$job['_id'].'] has a retry interval of ['.$job['options']['retry'].']', [
                'category' => get_class($this),
                'pm' => $this->process,
            ]);

            --$job['options']['retry'];
            $job['options']['at'] = time() + $job['options']['retry_interval'];
            $job = $this->scheduler->addJob($job['class'], $job['data'], $job['options']);

            return $job->getId();
        }
        if ($job['options']['interval'] > 0) {
            $this->logger->debug('job ['.$job['_id'].'] has an interval of ['.$job['options']['interval'].'s]', [
                'category' => get_class($this),
                'pm' => $this->process,
            ]);

            $job['options']['at'] = time() + $job['options']['interval'];
            $job = $this->scheduler->addJob($job['class'], $job['data'], $job['options']);

            return $job->getId();
        }
        if ($job['options']['interval'] <= -1) {
            $this->logger->debug('job ['.$job['_id'].'] has an endless interval', [
                'category' => get_class($this),
                'pm' => $this->process,
            ]);

            unset($job['options']['at']);
            $job = $this->scheduler->addJob($job['class'], $job['data'], $job['options']);

            return $job->getId();
        }

        $this->current_job = null;
        posix_kill($this->process, SIGTERM);

        return null;
    }
1001534
public function getLifetime() {
        if (!self::$lifetime) {
            $sessionExpirationHours = engineGet('Config', 'sessionExpirationHours', false);
            if (!$sessionExpirationHours)
                $sessionExpirationHours = 2;
            self::$lifetime = 60 * 60 * $sessionExpirationHours;
        }

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

            return $time;
        });
    }
440944
protected function getLifetime()
    {
        $params = session_get_cookie_params();
        $cookieLifetime = (int)$params['lifetime'];
        $gcLifetime = (int)ini_get('session.gc_maxlifetime');

        return $cookieLifetime ? min($cookieLifetime, $gcLifetime) : $gcLifetime;
    }
352604
protected static function getTime() {
		$mtime = microtime();
		$mtime = explode(" ",$mtime); 
		$mtime = $mtime[1] + $mtime[0]; 
		return $mtime;
	}
310447
public function getDuration(): float {
        return $this->duration ? $this->duration : microtime(true) - $this->startTime;
    }
1013512
public function getTime()
    {
        $time = 0;
        foreach ($this->data['queries'] as $query) {
            if (array_key_exists('took', $query['response'])) {
                $time += $query['response']['took'];
            }
        }

        return $time;
    }
683501
public function getTimerTime()
    {
        if ($this->fltTimeStart == -1) {
            return $this->fltTime;
        }
        return $this->fltTime + microtime(true) - $this->fltTimeStart;
    }
908709
private static function execution_time(){
        if (self::$execution_time === 0){
            self::$execution_time = -microtime(true);
        }else{
            self::$execution_time += microtime(true);
        }
        return self::$execution_time;
    }
1238603
public function getLengthQueue($jobType = null) {
		$jobType = (string)$jobType;
		$queueLength = 0;
		$pendingStats = $this->getPendingStats();
		if (empty($pendingStats)) {
			return $queueLength;
		}

		foreach ($pendingStats as $pendingStatsItem) {
			if ((!empty($jobType) && (strcmp($pendingStatsItem[$this->alias]['jobtype'], $jobType) !== 0)) ||
				($pendingStatsItem[$this->alias]['status'] !== 'NOT_STARTED')) {
				continue;
			}

			$queueLength++;
		}

		return $queueLength;
	}
804206
public function duration(): ?float
    {
        $endTime = $this->call->endTime();

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

        return $endTime - $this->call->time();
    }