-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbenchmark_types_arguments.php
73 lines (56 loc) · 1.49 KB
/
benchmark_types_arguments.php
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
//declare(strict_types=1);
/** @noinspection AutoloadingIssuesInspection */
$numbers = range(0, 1000);
include "Collection.php";
$instances=50000;
$exist=true;
class DummyClass {
}
/**
* @param DummyClass $arg1
* @param DummyClass $arg2
*
* @return DummyClass
*/
function php5($arg1,$arg2){
return new DummyClass();
}
function php7(DummyClass $arg1,DummyClass $arg2): DummyClass {
return new DummyClass();
}
function php5int($arg1,$arg2) {
return $arg1+$arg2;
}
function php7int(int $arg1,int $arg2) : int {
return $arg1+$arg2;
}
// **********************************************************************************
$t1=microtime(true);
for($i=0;$i<$instances;$i++) {
$r=php5(new DummyClass(),new DummyClass());
}
$t2=microtime(true);
$table['php5']=$t2-$t1;
// **********************************************************************************
$t1=microtime(true);
for($i=0;$i<$instances;$i++) {
$r=php7(new DummyClass(),new DummyClass());
}
$t2=microtime(true);
$table['php7']=$t2-$t1;
// **********************************************************************************
$t1=microtime(true);
for($i=0;$i<$instances;$i++) {
$r=php5int(20,"30");
}
$t2=microtime(true);
$table['php5int']=$t2-$t1;
// **********************************************************************************
$t1=microtime(true);
for($i=0;$i<$instances;$i++) {
$r=php7int(20,"30");
}
$t2=microtime(true);
$table['php7int']=$t2-$t1;
echo \mapache_commons\Collection::generateTable($table);