Commit 0cca79a
committed
zend_execute: Streamline typechecks in
For the callable.php vs closure.php benchmark:
$ taskset -c 0 hyperfine -L file callable.php,closure.php -L version before,after '/tmp/bench/{version} {file}'
Benchmark 1: /tmp/bench/before callable.php
Time (mean ± σ): 351.1 ms ± 2.8 ms [User: 348.3 ms, System: 2.0 ms]
Range (min … max): 349.3 ms … 359.0 ms 10 runs
Benchmark 2: /tmp/bench/before closure.php
Time (mean ± σ): 274.6 ms ± 2.4 ms [User: 270.9 ms, System: 2.9 ms]
Range (min … max): 273.3 ms … 281.5 ms 10 runs
Benchmark 3: /tmp/bench/after callable.php
Time (mean ± σ): 272.4 ms ± 0.5 ms [User: 270.3 ms, System: 2.0 ms]
Range (min … max): 271.6 ms … 273.3 ms 10 runs
Benchmark 4: /tmp/bench/after closure.php
Time (mean ± σ): 277.4 ms ± 2.2 ms [User: 274.3 ms, System: 2.4 ms]
Range (min … max): 275.7 ms … 283.3 ms 10 runs
Summary
/tmp/bench/after callable.php ran
1.01 ± 0.01 times faster than /tmp/bench/before closure.php
1.02 ± 0.01 times faster than /tmp/bench/after closure.php
1.29 ± 0.01 times faster than /tmp/bench/before callable.php
For the array_find benchmark:
Benchmark 1: /tmp/bench/before native.php
Time (mean ± σ): 627.6 ms ± 7.1 ms [User: 622.5 ms, System: 2.8 ms]
Range (min … max): 622.1 ms … 641.4 ms 10 runs
Benchmark 2: /tmp/bench/after native.php
Time (mean ± σ): 598.0 ms ± 5.5 ms [User: 594.4 ms, System: 2.7 ms]
Range (min … max): 589.9 ms … 604.9 ms 10 runs
Summary
/tmp/bench/after native.php ran
1.05 ± 0.02 times faster than /tmp/bench/before native.php
For a test with scalar types:
<?php
function func(string $f): string
{
return strrev($f);
}
for ($i = 0; $i < 10000000; $i++) {
func('abc');
}
the timings are:
Benchmark 1: /tmp/bench/before scalar.php
Time (mean ± σ): 212.5 ms ± 1.7 ms [User: 209.8 ms, System: 2.2 ms]
Range (min … max): 211.4 ms … 218.1 ms 14 runs
Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.
Benchmark 2: /tmp/bench/after scalar.php
Time (mean ± σ): 200.9 ms ± 2.0 ms [User: 198.0 ms, System: 2.4 ms]
Range (min … max): 199.7 ms … 207.2 ms 14 runs
Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.
Summary
/tmp/bench/after scalar.php ran
1.06 ± 0.01 times faster than /tmp/bench/before scalar.php
And a union type using only scalars:
<?php
function func(string|int $f): string
{
return strrev($f);
}
for ($i = 0; $i < 10000000; $i++) {
func('abc');
}
results in:
Benchmark 1: /tmp/bench/before union.php
Time (mean ± σ): 212.8 ms ± 1.8 ms [User: 210.0 ms, System: 2.2 ms]
Range (min … max): 212.0 ms … 219.0 ms 14 runs
Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.
Benchmark 2: /tmp/bench/after union.php
Time (mean ± σ): 200.1 ms ± 0.4 ms [User: 197.7 ms, System: 2.3 ms]
Range (min … max): 199.4 ms … 200.8 ms 14 runs
Summary
/tmp/bench/after union.php ran
1.06 ± 0.01 times faster than /tmp/bench/before union.php
Union types with objects are the only thing tested that were more or less the
same:
<?php
class A { public function get() { return 'abc'; } }
class B { }
function func(A|B $f): string
{
return strrev($f->get());
}
for ($i = 0; $i < 10000000; $i++) {
func(new A());
}
results in:
Benchmark 1: /tmp/bench/before union_obj.php
Time (mean ± σ): 700.6 ms ± 10.4 ms [User: 696.5 ms, System: 3.9 ms]
Range (min … max): 688.6 ms … 717.8 ms 10 runs
Benchmark 2: /tmp/bench/after union_obj.php
Time (mean ± σ): 706.7 ms ± 15.0 ms [User: 702.5 ms, System: 3.8 ms]
Range (min … max): 688.9 ms … 725.8 ms 10 runs
Summary
/tmp/bench/before union_obj.php ran
1.01 ± 0.03 times faster than /tmp/bench/after union_obj.phpzend_check_type_slow() if an object is given1 parent 8e216a2 commit 0cca79a
1 file changed
+22
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1088 | 1088 | | |
1089 | 1089 | | |
1090 | 1090 | | |
1091 | | - | |
1092 | | - | |
1093 | | - | |
| 1091 | + | |
1094 | 1092 | | |
1095 | 1093 | | |
1096 | 1094 | | |
| |||
1144 | 1142 | | |
1145 | 1143 | | |
1146 | 1144 | | |
1147 | | - | |
1148 | | - | |
1149 | | - | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
1150 | 1163 | | |
1151 | 1164 | | |
1152 | 1165 | | |
| |||
1158 | 1171 | | |
1159 | 1172 | | |
1160 | 1173 | | |
1161 | | - | |
| 1174 | + | |
1162 | 1175 | | |
1163 | 1176 | | |
1164 | 1177 | | |
1165 | 1178 | | |
1166 | 1179 | | |
1167 | 1180 | | |
1168 | 1181 | | |
1169 | | - | |
1170 | | - | |
1171 | | - | |
1172 | | - | |
1173 | | - | |
1174 | | - | |
1175 | | - | |
1176 | 1182 | | |
1177 | 1183 | | |
1178 | 1184 | | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
1182 | | - | |
1183 | | - | |
1184 | | - | |
1185 | | - | |
1186 | | - | |
1187 | | - | |
1188 | | - | |
1189 | | - | |
1190 | | - | |
| 1185 | + | |
| 1186 | + | |
1191 | 1187 | | |
1192 | 1188 | | |
1193 | 1189 | | |
| |||
0 commit comments