Utility function to measure the execution of a Closure

@param $label
@param \Closure $closure
@throws DebugBarException
963155
public function measure($label, \Closure $closure)
    {
        if ($this->hasCollector('time')) {
            /** @var \DebugBar\DataCollector\TimeDataCollector $collector */
            $collector = $this->getCollector('time');
            $collector->measure($label, $closure);
        }
    }
908108
public function where($label, \Closure $builder)
    {
        $this->input = $this->value;

        $condition = [$builder->bindTo($this)];

        return $this->joinGroup($label, $condition);
    }
741782
public function resolveClosure(\Closure $closure)
    {
        $reflection = new \ReflectionFunction($closure);

        $dependencies = $reflection->getParameters();
        $instances = $this->resolveDependencies($dependencies); // Actually resolve the dependencies
        $o = $reflection->invokeArgs($instances);

        return $o;
    }
1075241
public function iterateClosure($Closure, $Glue = false)
    {
        if (!is_callable($Closure) || empty($this->Input)) {
            return;
        }
        if (!$Glue) {
            foreach ($this->Working as &$Segment) {
                $Segment = $Closure($Segment);
            }
            return;
        }
        foreach ($this->Markers as &$Segment) {
            if (isset($Segment[0][0]) && !is_array($Segment[0][0])) {
                $Segment[0][0] = $Closure($Segment[0][0]);
            }
        }
    }
96594
public function requireWhen(\Closure $closure) {
        $need = $closure();
        $this->check_role = 'require';
        $result = true;
        if ($need) {
            $result = !empty($this->value) || '0' == $this->value;
        }
        $this->checkResult($result);
    }
156878
protected function handleRelationColumn($method, $label)
    {
        $model = $this->model()->eloquent();

        if (!method_exists($model, $method)) {
            return false;
        }

        if (!($relation = $model->$method()) instanceof Relation) {
            return false;
        }

        if ($relation instanceof HasOne || $relation instanceof BelongsTo) {
            $this->model()->with($method);

            return $this->addColumn($method, $label)->setRelation(snake_case($method));
        }

        if ($relation instanceof HasMany || $relation instanceof BelongsToMany || $relation instanceof MorphToMany) {
            $this->model()->with($method);

            return $this->addColumn(snake_case($method), $label);
        }

        return false;
    }
283709
public function byClosure(Closure $closure)
    {
        $this->controller = new Controller();
        if ($this->hasContainer() && method_exists($this->controller, 'raikiri'))
            $this->controller->setContainer($this->raikiri());

        $this->action = $closure->bindTo($this->controller);
    }
200121
public function call($closure, array $parameters = [], $buffer = false)
    {
        if ($buffer) {
            \ob_start();
        }

        $rslt = \call_user_func_array($closure, $parameters);

        if ($buffer) {
            return \ob_get_clean();
        }

        return $rslt;
    }
1262847
protected function createBlueprint($label, Closure $callback = null)
    {
        if (isset($this->resolver))
        {
            return call_user_func($this->resolver, $label, $callback);
        }
        else
        {
            return new Blueprint($label, $callback);
        }
    }
959847
protected function handleGetMutatorField($method, $label)
    {
        if (is_null($this->model)) {
            return false;
        }

        if ($this->model->hasGetMutator($method)) {
            return $this->addField($method, $label);
        }

        return false;
    }
480359
public static function addMeasure($label,$start,$stop){
		self::debugbar()->addMeasure($label,$start,$stop);
	}
1108788
protected function executeClosure(Closure $closure, array $parameters): Response
	{
		return $this->response->setBody($this->container->call($closure, $parameters));
	}
323082
public function beforeEach(\Closure $closure)
    {
        $key = 'beforeEach';
        $beforeEach = new Hook($key, $closure, $this->current);
        $this->current->setHook($key, $beforeEach);
    }
448223
public void deselectByLabel(String label) {
        getDispatcher().beforeDeselect(this, label);
        
        new Select(getElement()).deselectByVisibleText(label);
        if (Config.getBoolConfigProperty(ConfigProperty.ENABLE_GUI_LOGGING)) {
            logUIActions(UIActions.CLEARED, label);
        }
        
        getDispatcher().afterDeselect(this, label);
    }
1363098
public function scope($key, $label = '')
    {
        return tap(new Scope($key, $label), function (Scope $scope) {
            return $this->scopes->push($scope);
        });
    }
1297487
public function addLabel(Label $label)
    {
        if (!$this->labels->contains($label)) {
            $this->labels->add($label);
            $label->setInteractionMatching($this);
        }
    }
460735
public function inTransaction(Closure $closure): void
    {
        $connection = $this->getConnection();
        $connection->beginTransaction();
        try {
            $isOk = ($closure() === false ? null : true);
        } finally {
            $isCommitting = (isset($isOk) === true);
            try {
                $isCommitting === true ? $connection->commit() : $connection->rollBack();
            } /** @noinspection PhpRedundantCatchClauseInspection */ catch (ConEx | DBALException $exception) {
                throw new RepositoryException(
                    $isCommitting === true ? 'Failed to commit a transaction.' : 'Failed to rollback a transaction.',
                    0,
                    $exception
                );
            }
        }
    }