Skip to content

Commit

Permalink
no need to stack, since each call finishes before next starts
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul M. Jones committed Apr 3, 2016
1 parent aa54680 commit 4a53b1f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Profiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class Profiler implements ProfilerInterface
{
/**
*
* The current profile information in a stack to allow nesting.
* The current profile information.
*
* @var array
*
*/
private $stack = [];
private $profile = [];

/**
*
Expand Down Expand Up @@ -169,8 +169,7 @@ public function start($function)
}

// keep starting information in a stack
$profile = ['function' => $function, 'start' => microtime(true)];
array_push($this->stack, $profile);
$this->profile = ['function' => $function, 'start' => microtime(true)];
}

/**
Expand All @@ -190,8 +189,8 @@ public function finish($statement = null, array $values = [])
return;
}

$profile = array_pop($this->stack);
assert(! empty($profile)); // you are missing a call to begin()
$profile = $this->profile;
$this->profile = [];

$finish = microtime(true);
$profile['finish'] = $finish;
Expand Down

0 comments on commit 4a53b1f

Please sign in to comment.