Skip to content

Commit

Permalink
Tweak how memory usage is calculated. Fixes #1049
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnieezell committed Jul 10, 2018
1 parent 4e31dfb commit ca34c68
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
1 change: 0 additions & 1 deletion application/Filters/DebugToolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public function after(RequestInterface $request, ResponseInterface $response)
$data = $toolbar->run(
$stats['startTime'],
$stats['totalTime'],
$stats['startMemory'],
$request,
$response
);
Expand Down
8 changes: 0 additions & 8 deletions system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ class CodeIgniter
*/
protected $startTime;

/**
* Amount of memory at app start.
* @var int
*/
protected $startMemory;

/**
* Total app execution time
* @var float
Expand Down Expand Up @@ -144,7 +138,6 @@ class CodeIgniter
public function __construct($config)
{
$this->startTime = microtime(true);
$this->startMemory = memory_get_usage(true);
$this->config = $config;
}

Expand Down Expand Up @@ -562,7 +555,6 @@ public function getPerformanceStats()
return [
'startTime' => $this->startTime,
'totalTime' => $this->totalTime,
'startMemory' => $this->startMemory
];
}

Expand Down
5 changes: 2 additions & 3 deletions system/Debug/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,20 @@ public function __construct(BaseConfig $config)
*
* @param float $startTime App start time
* @param float $totalTime
* @param float $startMemory
* @param \CodeIgniter\HTTP\RequestInterface $request
* @param \CodeIgniter\HTTP\ResponseInterface $response
*
* @return string JSON encoded data
*/
public function run($startTime, $totalTime, $startMemory, $request, $response): string
public function run($startTime, $totalTime, $request, $response): string
{
// Data items used within the view.
$data['url'] = current_url();
$data['method'] = $request->getMethod(true);
$data['isAJAX'] = $request->isAJAX();
$data['startTime'] = $startTime;
$data['totalTime'] = $totalTime*1000;
$data['totalMemory'] = number_format((memory_get_peak_usage()-$startMemory)/1048576, 3);
$data['totalMemory'] = number_format((memory_get_peak_usage())/1024/1024, 3);
$data['segmentDuration'] = $this->roundTo($data['totalTime']/7, 5);
$data['segmentCount'] = (int)ceil($data['totalTime']/$data['segmentDuration']);
$data['CI_VERSION'] = \CodeIgniter\CodeIgniter::CI_VERSION;
Expand Down

0 comments on commit ca34c68

Please sign in to comment.