src/Debugger/Profiler.php
public static function finish(...$args)
    {
        if (Debugger::isProductionMode()) {
            return false;
        }

        if ([] === static::$stack) {
            throw new \RuntimeException('The stack is empty. Call Hail\Debugger\Profiler::start() first.');
        }

        $now = \microtime(true);
        $memoryUsage = \memory_get_usage(true);

        if (!isset($args[1])) {
            $label = $args[0] ?? static::getCurrentFileHashLine(1);
        } else {
            $label = \sprintf(...$args);
        }

        /** @var array $profile */
        $profile = \array_pop(static::$stack);
        $profile['meta'][self::FINISH_LABEL] = $label;
        $profile['meta'][self::FINISH_TIME] = $now;
        $profile['meta'][self::FINISH_MEMORY_USAGE] = $memoryUsage;
        $profile[self::ABSOLUTE_DURATION] = $profile['meta'][self::FINISH_TIME] - $profile['meta'][self::START_TIME];
        $profile[self::DURATION] = $profile[self::ABSOLUTE_DURATION] - $profile['meta'][self::TIME_OFFSET];
        $profile[self::ABSOLUTE_MEMORY_USAGE_CHANGE] = $profile['meta'][self::FINISH_MEMORY_USAGE] - $profile['meta'][self::START_MEMORY_USAGE];
        $profile[self::MEMORY_USAGE_CHANGE] = $profile[self::ABSOLUTE_MEMORY_USAGE_CHANGE] - $profile['meta'][self::MEMORY_USAGE_OFFSET];
        if ([] !== static::$stack) {
            $prefix = &static::$stack[\count(static::$stack) - 1]['meta'];
            $prefix[self::TIME_OFFSET] += $profile[self::ABSOLUTE_DURATION];
            $prefix[self::MEMORY_USAGE_OFFSET] += $profile[self::ABSOLUTE_MEMORY_USAGE_CHANGE];
        }

        self::$profiles[] = $profile;

        return $profile;
    }
public static function finish(...$args)
    {
        if (Debugger::isProductionMode()) {
            return false;
        }

        if ([] === static::$stack) {
            throw new \RuntimeException('The stack is empty. Call Hail\Debugger\Profiler::start() first.');
        }

        $now = \microtime(true);
        $memoryUsage = \memory_get_usage(true);

        if (!isset($args[1])) {
            $label = $args[0] ?? static::getCurrentFileHashLine(1);
        } else {
            $label = \sprintf(...$args);
        }

        /** @var array $profile */
        $profile = \array_pop(static::$stack);
        $profile['meta'][self::FINISH_LABEL] = $label;
        $profile['meta'][self::FINISH_TIME] = $now;
        $profile['meta'][self::FINISH_MEMORY_USAGE] = $memoryUsage;
        $profile[self::ABSOLUTE_DURATION] = $profile['meta'][self::FINISH_TIME] - $profile['meta'][self::START_TIME];
        $profile[self::DURATION] = $profile[self::ABSOLUTE_DURATION] - $profile['meta'][self::TIME_OFFSET];
        $profile[self::ABSOLUTE_MEMORY_USAGE_CHANGE] = $profile['meta'][self::FINISH_MEMORY_USAGE] - $profile['meta'][self::START_MEMORY_USAGE];
        $profile[self::MEMORY_USAGE_CHANGE] = $profile[self::ABSOLUTE_MEMORY_USAGE_CHANGE] - $profile['meta'][self::MEMORY_USAGE_OFFSET];
        if ([] !== static::$stack) {
            $prefix = &static::$stack[\count(static::$stack) - 1]['meta'];
            $prefix[self::TIME_OFFSET] += $profile[self::ABSOLUTE_DURATION];
            $prefix[self::MEMORY_USAGE_OFFSET] += $profile[self::ABSOLUTE_MEMORY_USAGE_CHANGE];
        }

        self::$profiles[] = $profile;

        return $profile;
    }
public static function finish ( ... $ args ) { if ( Debugger :: isProductionMode ( ) ) { return false ; } if ( [ ] === static :: $ stack ) { throw new \ RuntimeException ( 'The stack is empty. Call Hail\Debugger\Profiler::start() first.' ) ; } $ now = \ microtime ( true ) ; $ memoryUsage = \ memory_get_usage ( true ) ; if ( ! isset ( $ args [ 1 ] ) ) { $ label = $ args [ 0 ] ?? static :: getCurrentFileHashLine ( 1 ) ; } else { $ label = \ sprintf ( ... $ args ) ; } /** @var array $profile */ $ profile = \ array_pop ( static :: $ stack ) ; $ profile [ 'meta' ] [ self :: FINISH_LABEL ] = $ label ; $ profile [ 'meta' ] [ self :: FINISH_TIME ] = $ now ; $ profile [ 'meta' ] [ self :: FINISH_MEMORY_USAGE ] = $ memoryUsage ; $ profile [ self :: ABSOLUTE_DURATION ] = $ profile [ 'meta' ] [ self :: FINISH_TIME ] - $ profile [ 'meta' ] [ self :: START_TIME ] ; $ profile [ self :: DURATION ] = $ profile [ self :: ABSOLUTE_DURATION ] - $ profile [ 'meta' ] [ self :: TIME_OFFSET ] ; $ profile [ self :: ABSOLUTE_MEMORY_USAGE_CHANGE ] = $ profile [ 'meta' ] [ self :: FINISH_MEMORY_USAGE ] - $ profile [ 'meta' ] [ self :: START_MEMORY_USAGE ] ; $ profile [ self :: MEMORY_USAGE_CHANGE ] = $ profile [ self :: ABSOLUTE_MEMORY_USAGE_CHANGE ] - $ profile [ 'meta' ] [ self :: MEMORY_USAGE_OFFSET ] ; if ( [ ] !== static :: $ stack ) { $ prefix = & static :: $ stack [ \ count ( static :: $ stack ) - 1 ] [ 'meta' ] ; $ prefix [ self :: TIME_OFFSET ] += $ profile [ self :: ABSOLUTE_DURATION ] ; $ prefix [ self :: MEMORY_USAGE_OFFSET ] += $ profile [ self :: ABSOLUTE_MEMORY_USAGE_CHANGE ] ; } self :: $ profiles [ ] = $ profile ; return $ profile ; }
Finish profiling and get result

@param array ...$args

@return bool|array profile on success or false on failure
@throws \RuntimeException
Finish profiling and get result