Passed
Push — master ( 03282d...f5631a )
by Alexander
32:32 queued 17:38
created

PerformanceMetrics::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace App\Widget;
5
6
use App\Timer;
7
use Yiisoft\Widget\Widget;
8
9
class PerformanceMetrics extends Widget
10
{
11
    private Timer $timer;
12
13
    public function __construct(Timer $timer)
14
    {
15
        $this->timer = $timer;
16
    }
17
18
    protected function run(): string
19
    {
20
        $time = round($this->timer->get('overall'), 4);
21
        $memory = round(memory_get_peak_usage() / (1024 * 1024), 4);
22
23
        return "Time: $time s. Memory: $memory mb.";
24
    }
25
}
26