Passed
Pull Request — master (#342)
by
unknown
17:18 queued 08:55
created

CBench::getmicrotime()   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
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 9.4285
1
<?php
2
/***************************************************************************
3
 *  For license information see doc/license.txt
4
 *
5
 *  Unicode Reminder メモ
6
 *
7
 *  Exact time mesurement
8
 ***************************************************************************/
9
10
class CBench
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
11
{
12
    public $start;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
13
    public $stop;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
14
15
    public function CBench()
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
16
    {
17
        $this->start = 0;
18
        $this->stop = 0;
19
    }
20
21
    public function getmicrotime()
22
    {
23
        list($usec, $sec) = explode(' ', microtime());
24
25
        return ((float)$usec + (float)$sec);
0 ignored issues
show
introduced by
Language constructs must not be followed by parenthesesis.
Loading history...
26
    }
27
28
    public function start()
29
    {
30
        $this->start = $this->getmicrotime();
31
    }
32
33
    public function stop()
34
    {
35
        $this->stop = $this->getmicrotime();
36
    }
37
38
    public function diff()
39
    {
40
        $result = $this->stop - $this->start;
41
42
        return $result;
43
    }
44
45
    public function runTime()
46
    {
47
        $result = $this->getmicrotime() - $this->start;
48
49
        return $result;
50
    }
51
}
52