获取资源消耗
@param int $startTime
@param int $startMem
@return array
504433
public static function runtime($startTime, $startMem)
    {
        // 显示运行时间
        $return['time'] = number_format(microtime(true) - $startTime, 4) . 's';
        $startMem = (int)array_sum(explode(' ', $startMem));
        $endMem = array_sum(explode(' ', memory_get_usage()));
        $return['memory'] = number_format(($endMem - $startMem) / 1024) . 'kb';

        return $return;
    }
980881
protected function setStartTime($startTime)
	{
		if ( ! is_numeric($startTime))
		{
			throw new \InvalidArgumentException('Wrong start time value.');
		}
		
		$this->startTime = (float) $startTime;
		
		return $this;
	}
1245584
public function uptime(string $startedAt, string $endedAt, string $split)
    {
        return $this->ohDear->uptime($this->id, $startedAt, $endedAt, $split);
    }
1280802
public static function getMemPeak( $start, $end, $dec = 2 )
	{
		if( !isset( self::$mem['peak'][$end] ) ){
			self::$mem['peak'][$end] = memory_get_peak_usage();
		}
		$size = self::$mem['peak'][$end] - self::$mem['peak'][$start];
		$a    = ['B', 'KB', 'MB', 'GB', 'TB'];
		$pos  = 0;
		while( $size >= 1024 ){
			$size /= 1024;
			$pos ++;
		}
		return round( $size, $dec )." ".$a[$pos];
	}
574583
public function getLeads($startDate, $endDate, array $params = array())
    {
        $isValidStartDate = $this->utils->isSystemDatetime($startDate);
        $isValidEndDate = $this->utils->isSystemDatetime($endDate);
        if (!$isValidEndDate || !$isValidStartDate) {
            throw new InvalidArgumentException('Invalid params: Only system date has available YYYY-MM-DDD HH:II:SS');
        }

        if ($startDate > $endDate) {
            throw new InvalidArgumentException('Invalid params: start_date > end_date');
        }

        $isOutOfLimit = $this->utils->isOutOfLimit($startDate, $endDate, LeadAcademic::LIMIT_PERIOD);
        if ($isOutOfLimit) {
            throw new InvalidArgumentException('Invalid params: Period is too large. Available only ' . LeadAcademic::LIMIT_PERIOD);
        }

        $params['date_lbound'] = $startDate;
        $params['date_ubound'] = $endDate;

        $this->normalizeParams($params);
        $response = $this->execute('/', $params);
        $data = $this->normalize($response);
        return $data['leads'];
    }
1321332
public static function getTakenTime($startTimestamp, $endTimestamp)
    {
        // Mostly used format
        $format = 'Y-m-d H:i:s';

        $datetime1 = new DateTime(date($format, $startTimestamp));
        $datetime2 = new DateTime(date($format, $endTimestamp));

        $interval = $datetime1->diff($datetime2);
        return $interval->format('%H:%I:%S');    
    }
158858
public function allStartingWith(string $startingWith = '') : array
    {
        $values = $this->all();

        if ($startingWith === '') {
            return $values;
        }

        return $this->filterKeysStartingWith($values, $startingWith);
    }
1247540
protected function get_activities($starttime, $endtime, $student = false) {

        $activitytype = $this->get_activity_type();

        // Var $student may not be available, default to not calculating dynamic data.
        $studentid = -1;
        if ($student) {
            $studentid = $student->id;
        }
        $modinfo = get_fast_modinfo($this->course->get_course_data(), $studentid);
        $activities = $modinfo->get_instances_of($activitytype);

        $timerangeactivities = array();
        foreach ($activities as $activity) {

            if (!$this->activity_completed_by($activity, $starttime, $endtime, $student)) {
                continue;
            }

            $timerangeactivities[$activity->context->id] = $activity;
        }

        return $timerangeactivities;
    }
212265
public static function dateDiff($interval, $startDateTime, $endDateTime)
    {
        $diff = static::getTimestamp($endDateTime) - static::getTimestamp($startDateTime);
        switch ($interval) {
            case 'Y' : // 年
                $result = bcdiv($diff, 60 * 60 * 24 * 365);
                break;
            case 'M' : // 月
                $result = bcdiv($diff, 60 * 60 * 24 * 30);
                break;
            case 'W' : // 星期
                $result = bcdiv($diff, 60 * 60 * 24 * 7);
                break;
            case 'D' : // 日
                $result = bcdiv($diff, 60 * 60 * 24);
                break;
            case 'H' : // 时
                $result = bcdiv($diff, 60 * 60);
                break;
            case 'N' : // 分
                $result = bcdiv($diff, 60);
                break;
            case 'S' : // 秒
            default :
                $result = $diff;
                break;
        }
        return $result;
    }
1278855
static public function elapsed($start, $end) {
        return [
                'time_elapsed' => self::elapsedTime($start, $end),
                'memory_usage_gap' => self::elapsedMemory($start, $end),
                'real_memory_usage' => self::elapsedMemory($start, $end, true)
            ];
    }
44050
public function getStartTime() {
        if (!isset($this->startTime)) {
            $this->startTime = (string)$this->getData(OntologyDeliveryExecution::PROPERTY_TIME_START);
        }
        return $this->startTime;
    }
1196746
public static function fromString($startTime, $endTime)
    {
        return new self(Time::fromString($startTime), Time::fromString($endTime));
    }
931159
public function queueDelayed($endTime = null, $startTime = 0)
    {
        $startTime = $startTime ?: 0;
        $endTime = $endTime ?: time();

        foreach ($this->resolveQueues() as $queue) {
            $this->redis->multi();
            $jobs = $this->redis->zrangebyscore(Queue::redisKey($queue, 'delayed'), $startTime, $endTime);
            $this->redis->zremrangebyscore(Queue::redisKey($queue, 'delayed'), $startTime, $endTime);
            list($jobs, $found) = $this->redis->exec();

            if ($found > 0) {
                foreach ($jobs as $payload) {
                    $job = Job::loadPayload($queue, $payload);
                    $job->setWorker($this);

                    if (Event::fire(Event::JOB_QUEUE_DELAYED, $job) !== false) {
                        $job->queue();

                        Event::fire(Event::JOB_QUEUED_DELAYED, $job);
                    }
                }

                Stats::decr('delayed', $found);
                Stats::decr('delayed', $found, Queue::redisKey($queue, 'stats'));

                $this->log('Added <pop>'.$found.'</pop> delayed job'.($found == 1 ? '' : 's').' to <pop>'.$queue.'</pop> queue', Logger::NOTICE);
            }
        }
    }
324378
public function getHubWindowAtThisTime(\DateTime $startTime, $delivery_type)
    {
        $windows = $this->getHubWindowsIndexedByStartTimeAndDeliveryType();

        if (!empty($windows[$startTime->format(\DateTime::ATOM)][$delivery_type]))
        {
            return $windows[$startTime->format(\DateTime::ATOM)][$delivery_type];
        }

        return false;
    }
270066
public function selectByRank(int $start = 0, int $stop = -1, bool $desc = false): array
    {
        //按降序获取
        if ($desc) {
            return $this->handle->zRevRange($this->name, $start, $stop, true);
        }

        //按升序获取
        return $this->handle->zRange($this->name, $start, $stop, true);
    }
195902
private function getInvoices(DateTime $startDate, DateTime $endDate)
    {
        $offset = Mirakl::MIRAKL_API_MAX_PAGINATE;

        $invoicesData = $this->mirakl->getInvoices(
            $startDate,
            $endDate
        );

        $invoices = array_merge(array(), $invoicesData['invoices']);

        $total = $invoicesData['total_count'];

        while ($total % $offset !== $total) {

            $invoicesData = $this->mirakl->getInvoices(
                $startDate,
                $endDate,
                Mirakl::MIRAKL_API_MAX_PAGINATE,
                $offset
            );

            $invoices = array_merge($invoices, $invoicesData['invoices']);

            $offset += Mirakl::MIRAKL_API_MAX_PAGINATE;
        }

        return $invoices;
    }
43285
private function getGroup($start = "WHERE",$table = NULL)
    {
        if(count($this->group))
        {
            $temp = [];
            foreach($this->group as $k=>$v)
                $temp[] = (!empty($table) ? $table."." : '')."`".$k."` = '".$v."'";
            return $start." ".implode(' AND ',$temp);
        }
        else
            return '';
    }