-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChainCallTest.php
More file actions
52 lines (41 loc) · 1006 Bytes
/
ChainCallTest.php
File metadata and controls
52 lines (41 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
use PHPUnit\Framework\TestCase;
class TestClass
{
private static $sum = 0;
public function addChain()
{
self::$sum++;
return $this;
}
public function add()
{
self::$sum++;
}
}
final class ChainCallTest extends TestCase
{
protected $count = 1000000;
public function testWithoutChain()
{
$testclass = new TestClass();
$timer = Benchmark::getInstance();
$timer ->Start();
for ($i = 0;$i < $this -> count;$i++) {
$testclass -> add();
}
$timer -> Stop();
echo "Without Chain is :: ". $timer -> GetTime().PHP_EOL;
}
public function testWtihChain()
{
$testclass = new TestClass();
$timer = Benchmark::getInstance();
$timer ->Start();
for ($i = 0;$i < $this -> count;$i++) {
$testclass -> addChain();
}
$timer -> Stop();
echo "With Chain is :: ". $timer -> GetTime().PHP_EOL;
}
}