1
1
<?php
2
2
3
3
/**
4
- * Special test only for php 5+.
4
+ * Special test only for php 5+
5
5
* php 4.x can't compile try construction.
6
6
*/
7
+
8
+ /* ------------------------ Additional data ------------------------ */
9
+
10
+ class PublicProperties
11
+ {
12
+ public $ number = 0 ;
13
+ }
14
+
15
+ class GetterSetter
16
+ {
17
+ private $ number = 0 ;
18
+
19
+ public function getNumber ()
20
+ {
21
+ return $ this ->number ;
22
+ }
23
+
24
+ public function setNumber ($ new )
25
+ {
26
+ $ this ->number = $ new ;
27
+ return $ this ;
28
+ }
29
+ }
30
+
31
+ class MagicMethods
32
+ {
33
+ private $ number = 0 ;
34
+
35
+ public function __get ($ name )
36
+ {
37
+ if ($ name === 'number ' ) {
38
+ return $ this ->number ;
39
+ }
40
+ return null ;
41
+ }
42
+
43
+ public function __set ($ name , $ new )
44
+ {
45
+ if ($ name === 'number ' ) {
46
+ $ this ->number = $ new ;
47
+ }
48
+ }
49
+ }
50
+
51
+ /* ------------------------ Tests ------------------------ */
52
+
7
53
function test_21_0_Loop_Exception_None ()
8
54
{
9
- global $ testsLoopLimits ;
55
+ global $ testsLoopLimits, $ totalOps ;
10
56
11
57
$ count = $ testsLoopLimits ['21_loop_except ' ];
12
58
$ time_start = get_microtime ();
13
59
for ($ i = 0 ; $ i < $ count ; $ i ++) {
14
60
$ a = $ i ;
15
61
}
62
+ $ totalOps += $ count ;
16
63
return format_result_test (get_microtime () - $ time_start , $ count , mymemory_usage ());
17
64
}
18
65
19
66
function test_21_1_Loop_Exception_Try ()
20
67
{
21
- global $ testsLoopLimits ;
68
+ global $ testsLoopLimits, $ totalOps ;
22
69
23
70
$ count = $ testsLoopLimits ['21_loop_except ' ];
24
71
$ time_start = get_microtime ();
@@ -28,12 +75,13 @@ function test_21_1_Loop_Exception_Try()
28
75
} catch (Exception $ e ) {
29
76
}
30
77
}
78
+ $ totalOps += $ count ;
31
79
return format_result_test (get_microtime () - $ time_start , $ count , mymemory_usage ());
32
80
}
33
81
34
82
function test_21_2_Loop_Exception_Catch ()
35
83
{
36
- global $ testsLoopLimits ;
84
+ global $ testsLoopLimits, $ totalOps ;
37
85
38
86
$ count = $ testsLoopLimits ['21_loop_except ' ];
39
87
$ time_start = get_microtime ();
@@ -44,5 +92,58 @@ function test_21_2_Loop_Exception_Catch()
44
92
} catch (Exception $ e ) {
45
93
}
46
94
}
95
+ $ totalOps += $ count ;
96
+ return format_result_test (get_microtime () - $ time_start , $ count , mymemory_usage ());
97
+ }
98
+
99
+ function test_26_1_Class_Public_Properties ()
100
+ {
101
+ global $ testsLoopLimits , $ totalOps ;
102
+
103
+ $ c = new PublicProperties ();
104
+ $ r = 0 ;
105
+
106
+ $ count = $ testsLoopLimits ['26_1_public ' ];
107
+ $ time_start = get_microtime ();
108
+ for ($ i = 0 ; $ i < $ count ; $ i ++) {
109
+ $ r = $ c ->number ;
110
+ $ c ->number = $ r + $ i ;
111
+ }
112
+ $ totalOps += $ count ;
47
113
return format_result_test (get_microtime () - $ time_start , $ count , mymemory_usage ());
48
114
}
115
+
116
+ function test_26_2_Class_Getter_Setter ()
117
+ {
118
+ global $ testsLoopLimits , $ totalOps ;
119
+
120
+ $ c = new GetterSetter ();
121
+ $ r = 0 ;
122
+
123
+ $ count = $ testsLoopLimits ['26_1_getset ' ];
124
+ $ time_start = get_microtime ();
125
+ for ($ i = 0 ; $ i < $ count ; $ i ++) {
126
+ $ r = $ c ->getNumber ();
127
+ $ c ->setNumber ($ r + $ i );
128
+ }
129
+ $ totalOps += $ count ;
130
+ return format_result_test (get_microtime () - $ time_start , $ count , mymemory_usage ());
131
+ }
132
+
133
+ function test_26_2_Class_Magic_Methods ()
134
+ {
135
+ global $ testsLoopLimits , $ totalOps ;
136
+
137
+ $ c = new MagicMethods ();
138
+ $ r = 0 ;
139
+
140
+ $ count = $ testsLoopLimits ['26_1_magic ' ];
141
+ $ time_start = get_microtime ();
142
+ for ($ i = 0 ; $ i < $ count ; $ i ++) {
143
+ $ r = $ c ->number ;
144
+ $ c ->number = $ r + $ i ;
145
+ }
146
+ $ totalOps += $ count ;
147
+ return format_result_test (get_microtime () - $ time_start , $ count , mymemory_usage ());
148
+ }
149
+
0 commit comments