Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
44.44% |
4 / 9 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
LggrPerf | |
44.44% |
4 / 9 |
|
66.67% |
2 / 3 |
9.29 | |
0.00% |
0 / 1 |
__construct | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
start | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
stop | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getPerf | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
logPerf | n/a |
0 / 0 |
n/a |
0 / 0 |
1 |
1 | <?php |
2 | namespace Lggr; |
3 | |
4 | /** |
5 | * @class LggrPerf |
6 | * @brief Performance measurement class. |
7 | * |
8 | * Yet an empty skeleton, has to get more functionality. |
9 | */ |
10 | class LggrPerf { |
11 | |
12 | private $tsStart = null; /** timestamp start */ |
13 | |
14 | private $tsEnd = null; /** timestamp end */ |
15 | |
16 | private $tsLen = null; /** calculated seconds */ |
17 | |
18 | private $sQuery = null; /** Stored SQL query to be measured */ |
19 | |
20 | /** |
21 | * Empty constructor |
22 | */ |
23 | function __construct() { |
24 | // nothing to do here |
25 | } |
26 | |
27 | /** |
28 | * Start timer and store query |
29 | * @param String sql query |
30 | */ |
31 | public function start($sql) { |
32 | $this->sQuery = $sql; |
33 | $this->tsStart = microtime(true); |
34 | } |
35 | |
36 | /** |
37 | * Stop timer and store length |
38 | */ |
39 | public function stop() { |
40 | $this->tsEnd = microtime(true); |
41 | $this->tsLen = $this->tsEnd - $this->tsStart; |
42 | } |
43 | |
44 | /** |
45 | * Return array with time and query |
46 | * @return array with keys time and query |
47 | */ |
48 | public function getPerf() { |
49 | $a = array(); |
50 | |
51 | $a['time'] = $this->tsLen; |
52 | $a['query'] = $this->sQuery; |
53 | |
54 | $this->logperf(); |
55 | |
56 | return $a; |
57 | } |
58 | |
59 | /** |
60 | * TODO write performance info to logging layer |
61 | */ |
62 | private function logPerf() {} |
63 | } |
64 |