3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php define('NUM_INSTANCES', 10); define('NUM_TESTS', 10000); class TestObject { public $a; public $b; public $c; public function __construct($a,$b,$c) { $this->a = $a; $this->b = $b; $this->c = $c; } } class Test { public function getObjects() { $a = array(); for ($i=0; $i<NUM_INSTANCES; $i++) $a[] = new TestObject('a','b','c'); return $a; } public function getArrays() { $a = array(); for ($i=0; $i<NUM_INSTANCES; $i++) $a[] = $this->buildArray('a', 'b', 'c'); return $a; } public function buildArray($a, $b, $c) { $array = array(); $array['a'] = $a; $array['b'] = $b; $array['c'] = $c; return $array; } public function useObject($o) { $a = $o->a; $b = $o->b; $o->c = 'xxx'; } public function useArray($o) { $a = $o['a']; $b = $o['b']; $o['c'] = 'xxx'; } } $test = new Test; // Benchmark with objects: $start = microtime(true); for ($i=0; $i<NUM_TESTS; $i++) { $x = $test->getObjects(); foreach ($x as $y) $test->useObject($y); } echo "\nObject time = " . (microtime(true)-$start) . "\n\n"; // Benchmark with arrays: $start = microtime(true); for ($i=0; $i<NUM_TESTS; $i++) { $x = $test->getArrays(); foreach ($x as $y) $test->useArray($y); } echo "\nArray time = " . (microtime(true)-$start) . "\n\n";
Output for 7.1.0
Object time = 0.023049116134644 Array time = 0.02650785446167
Output for 7.0.14
Object time = 0.039461135864258 Array time = 0.040086030960083
Output for 7.0.11
Object time = 0.029605150222778 Array time = 0.030415058135986
Output for 7.0.10
Object time = 0.024922132492065 Array time = 0.025166988372803
Output for 7.0.9
Object time = 0.020526885986328 Array time = 0.025019884109497
Output for 7.0.8
Object time = 0.02190899848938 Array time = 0.025887012481689
Output for 7.0.7
Object time = 0.029711008071899 Array time = 0.032156944274902
Output for 7.0.6
Object time = 0.02614688873291 Array time = 0.031440019607544
Output for 7.0.5
Object time = 0.020642995834351 Array time = 0.025266885757446
Output for 7.0.4
Object time = 0.022432088851929 Array time = 0.025922060012817
Output for 7.0.3
Object time = 0.020604848861694 Array time = 0.025429964065552
Output for 7.0.2
Object time = 0.027009963989258 Array time = 0.026374816894531
Output for 7.0.1
Object time = 0.031922101974487 Array time = 0.034924030303955
Output for 7.0.0
Object time = 0.024960041046143 Array time = 0.029096841812134
Output for 5.6.28
Object time = 0.10144782066345 Array time = 0.09695291519165
Output for 5.6.26
Object time = 0.074888944625854 Array time = 0.079210042953491
Output for 5.6.25
Object time = 0.081434965133667 Array time = 0.083997964859009
Output for 5.6.24
Object time = 0.06344199180603 Array time = 0.079180955886841
Output for 5.6.23
Object time = 0.06373119354248 Array time = 0.079493999481201
Output for 5.6.22
Object time = 0.062114000320435 Array time = 0.078810930252075
Output for 5.6.21
Object time = 0.063922882080078 Array time = 0.081214904785156
Output for 5.6.20
Object time = 0.062695026397705 Array time = 0.080164909362793
Output for 5.6.19
Object time = 0.062307119369507 Array time = 0.079369068145752
Output for 5.6.18
Object time = 0.077066898345947 Array time = 0.081571102142334
Output for 5.6.17
Object time = 0.08017897605896 Array time = 0.079653024673462
Output for 5.6.16
Object time = 0.072829008102417 Array time = 0.079186916351318
Output for 5.6.15
Object time = 0.078258037567139 Array time = 0.081687927246094
Output for 5.6.14
Object time = 0.071844100952148 Array time = 0.081913948059082
Output for 5.6.13
Object time = 0.069170951843262 Array time = 0.080323934555054
Output for 5.6.12
Object time = 0.090115070343018 Array time = 0.088338136672974
Output for 5.6.11
Object time = 0.085447788238525 Array time = 0.07996392250061
Output for 5.6.10
Object time = 0.0728440284729 Array time = 0.079901933670044
Output for 5.6.9
Object time = 0.087089061737061 Array time = 0.086692094802856
Output for 5.6.8
Object time = 0.080366849899292 Array time = 0.10363507270813
Output for 5.6.7
Object time = 0.07908296585083 Array time = 0.081401109695435
Output for 5.6.6
Object time = 0.087796926498413 Array time = 0.088783979415894
Output for 5.6.5
Object time = 0.068481922149658 Array time = 0.080393075942993
Output for 5.6.4
Object time = 0.090857028961182 Array time = 0.089538097381592
Output for 5.6.3
Object time = 0.088454961776733 Array time = 0.088343858718872
Output for 5.6.2
Object time = 0.079655885696411 Array time = 0.079298973083496
Output for 5.6.1
Object time = 0.062808990478516 Array time = 0.079976081848145
Output for 5.6.0
Object time = 0.078451156616211 Array time = 0.081615924835205
Output for 5.5.38
Object time = 0.063091993331909 Array time = 0.078808069229126
Output for 5.5.37
Object time = 0.068205118179321 Array time = 0.081640005111694
Output for 5.5.36
Object time = 0.067811012268066 Array time = 0.08568286895752
Output for 5.5.35
Object time = 0.071422100067139 Array time = 0.094570875167847
Output for 5.5.34
Object time = 0.068288087844849 Array time = 0.086925983428955
Output for 5.5.33
Object time = 0.069664001464844 Array time = 0.091820955276489
Output for 5.5.32
Object time = 0.074720859527588 Array time = 0.082770109176636
Output for 5.5.31
Object time = 0.094717025756836 Array time = 0.09308910369873
Output for 5.5.30
Object time = 0.079464912414551 Array time = 0.085378885269165
Output for 5.5.29
Object time = 0.080711126327515 Array time = 0.086925983428955
Output for 5.5.28
Object time = 0.083788156509399 Array time = 0.082163095474243
Output for 5.5.27
Object time = 0.074105024337769 Array time = 0.085361003875732
Output for 5.5.26
Object time = 0.082900047302246 Array time = 0.087868928909302
Output for 5.5.25
Object time = 0.07911205291748 Array time = 0.085413932800293
Output for 5.5.24
Object time = 0.072191953659058 Array time = 0.086822986602783
Output for 5.5.23
Object time = 0.069195032119751 Array time = 0.082751035690308
Output for 5.5.22
Object time = 0.084891080856323 Array time = 0.082626104354858
Output for 5.5.21
Object time = 0.071662187576294 Array time = 0.083302974700928
Output for 5.5.20
Object time = 0.068388938903809 Array time = 0.08219313621521
Output for 5.5.19
Object time = 0.074604034423828 Array time = 0.086527109146118
Output for 5.5.18
Object time = 0.084405899047852 Array time = 0.081308126449585
Output for 5.5.16
Object time = 0.075237035751343 Array time = 0.082222938537598
Output for 5.5.15
Object time = 0.084933996200562 Array time = 0.098680973052979
Output for 5.5.14
Object time = 0.078528881072998 Array time = 0.082545042037964
Output for 5.5.13
Object time = 0.081737995147705 Array time = 0.085042953491211
Output for 5.5.12
Object time = 0.094742059707642 Array time = 0.093454122543335
Output for 5.5.11
Object time = 0.076460838317871 Array time = 0.082870960235596
Output for 5.5.10
Object time = 0.075030088424683 Array time = 0.084410905838013
Output for 5.5.9
Object time = 0.077244997024536 Array time = 0.081814050674438
Output for 5.5.8
Object time = 0.072524070739746 Array time = 0.083634853363037
Output for 5.5.7
Object time = 0.087440013885498 Array time = 0.083026885986328
Output for 5.5.6
Object time = 0.073099136352539 Array time = 0.082460880279541
Output for 5.5.5
Object time = 0.076062202453613 Array time = 0.086199998855591
Output for 5.5.4
Object time = 0.082483053207397 Array time = 0.086900949478149
Output for 5.5.3
Object time = 0.082432985305786 Array time = 0.086092948913574
Output for 5.5.2
Object time = 0.077924013137817 Array time = 0.083345890045166
Output for 5.5.1
Object time = 0.08299994468689 Array time = 0.086462020874023
Output for 5.5.0
Object time = 0.066509008407593 Array time = 0.082413911819458
Output for 5.4.45
Object time = 0.073007106781006 Array time = 0.083095073699951
Output for 5.4.44
Object time = 0.071200847625732 Array time = 0.082568883895874
Output for 5.4.43
Object time = 0.081260919570923 Array time = 0.08671498298645
Output for 5.4.42
Object time = 0.079282999038696 Array time = 0.082762956619263
Output for 5.4.41
Object time = 0.091248035430908 Array time = 0.091523885726929
Output for 5.4.40
Object time = 0.073784112930298 Array time = 0.084395885467529
Output for 5.4.39
Object time = 0.084961175918579 Array time = 0.10987401008606
Output for 5.4.38
Object time = 0.073838949203491 Array time = 0.088295936584473
Output for 5.4.37
Object time = 0.079158067703247 Array time = 0.084271192550659
Output for 5.4.36
Object time = 0.064677000045776 Array time = 0.083498954772949
Output for 5.4.35
Object time = 0.093023061752319 Array time = 0.087385892868042
Output for 5.4.34
Object time = 0.070657968521118 Array time = 0.086772918701172
Output for 5.4.32
Object time = 0.072931051254272 Array time = 0.083389043807983
Output for 5.4.31
Object time = 0.08739709854126 Array time = 0.086119890213013
Output for 5.4.30
Object time = 0.090405941009521 Array time = 0.08965015411377
Output for 5.4.29
Object time = 0.090514183044434 Array time = 0.090395927429199
Output for 5.4.28
Object time = 0.089946985244751 Array time = 0.091030120849609
Output for 5.4.27
Object time = 0.071846008300781 Array time = 0.082415103912354
Output for 5.4.26
Object time = 0.067713022232056 Array time = 0.082551956176758
Output for 5.4.25
Object time = 0.092890024185181 Array time = 0.093065977096558
Output for 5.4.24
Object time = 0.083214998245239 Array time = 0.085839986801147
Output for 5.4.23
Object time = 0.07346510887146 Array time = 0.084359169006348
Output for 5.4.22
Object time = 0.080034971237183 Array time = 0.084126949310303
Output for 5.4.21
Object time = 0.090095996856689 Array time = 0.090363025665283
Output for 5.4.20
Object time = 0.08725905418396 Array time = 0.091372013092041
Output for 5.4.19
Object time = 0.087671995162964 Array time = 0.085286140441895
Output for 5.4.18
Object time = 0.094614028930664 Array time = 0.093589067459106
Output for 5.4.17
Object time = 0.063731908798218 Array time = 0.08282208442688
Output for 5.4.16
Object time = 0.080649137496948 Array time = 0.090539932250977
Output for 5.4.15
Object time = 0.083847999572754 Array time = 0.11206889152527
Output for 5.4.14
Object time = 0.071966886520386 Array time = 0.0814368724823
Output for 5.4.13
Object time = 0.090213060379028 Array time = 0.088812112808228
Output for 5.4.12
Object time = 0.087980985641479 Array time = 0.086473941802979
Output for 5.4.11
Object time = 0.074988126754761 Array time = 0.083429098129272
Output for 5.4.10
Object time = 0.083659172058105 Array time = 0.088176965713501
Output for 5.4.9
Object time = 0.076380014419556 Array time = 0.084324836730957
Output for 5.4.8
Object time = 0.083570957183838 Array time = 0.086650848388672
Output for 5.4.7
Object time = 0.071645975112915 Array time = 0.083254098892212
Output for 5.4.6
Object time = 0.081938982009888 Array time = 0.0848069190979
Output for 5.4.5
Object time = 0.074980974197388 Array time = 0.084124088287354
Output for 5.4.4
Object time = 0.09312891960144 Array time = 0.097616910934448
Output for 5.4.3
Object time = 0.064101934432983 Array time = 0.084367036819458
Output for 5.4.2
Object time = 0.083338022232056 Array time = 0.085811138153076
Output for 5.4.1
Object time = 0.094145059585571 Array time = 0.093981027603149
Output for 5.4.0
Object time = 0.080164909362793 Array time = 0.081256151199341
Output for 5.3.29
Object time = 0.1402850151062 Array time = 0.10930204391479
Output for 5.3.28
Object time = 0.12603712081909 Array time = 0.10795903205872
Output for 5.3.27
Object time = 0.11616706848145 Array time = 0.1093008518219
Output for 5.3.26
Object time = 0.13019990921021 Array time = 0.1081018447876
Output for 5.3.25
Object time = 0.14012813568115 Array time = 0.1083881855011
Output for 5.3.24
Object time = 0.1365180015564 Array time = 0.1123960018158
Output for 5.3.23
Object time = 0.12221789360046 Array time = 0.10869693756104
Output for 5.3.22
Object time = 0.12152314186096 Array time = 0.10930204391479
Output for 5.3.21
Object time = 0.13406801223755 Array time = 0.10813403129578
Output for 5.3.20
Object time = 0.1191771030426 Array time = 0.10787296295166
Output for 5.3.19
Object time = 0.13561820983887 Array time = 0.10705304145813
Output for 5.3.18
Object time = 0.13098287582397 Array time = 0.10760116577148
Output for 5.3.17
Object time = 0.13290286064148 Array time = 0.10610485076904
Output for 5.3.16
Object time = 0.12377691268921 Array time = 0.10805106163025
Output for 5.3.15
Object time = 0.13729691505432 Array time = 0.11702394485474
Output for 5.3.14
Object time = 0.1313750743866 Array time = 0.10951018333435
Output for 5.3.13
Object time = 0.14012002944946 Array time = 0.11352896690369
Output for 5.3.12
Object time = 0.12172293663025 Array time = 0.10726881027222
Output for 5.3.11
Object time = 0.13171601295471 Array time = 0.10709810256958
Output for 5.3.10
Object time = 0.11944508552551 Array time = 0.11021995544434
Output for 5.3.9
Object time = 0.12637090682983 Array time = 0.10758280754089
Output for 5.3.8
Object time = 0.13507890701294 Array time = 0.11007690429688
Output for 5.3.7
Object time = 0.13442611694336 Array time = 0.10899901390076
Output for 5.3.6
Object time = 0.12703800201416 Array time = 0.1108660697937
Output for 5.3.5
Object time = 0.11846804618835 Array time = 0.10835099220276
Output for 5.3.4
Object time = 0.14504599571228 Array time = 0.10957908630371
Output for 5.3.3
Object time = 0.14089488983154 Array time = 0.10840010643005
Output for 5.3.2
Object time = 0.146164894104 Array time = 0.10937905311584
Output for 5.3.1
Object time = 0.12067699432373 Array time = 0.11097812652588
Output for 5.3.0
Object time = 0.13646292686462 Array time = 0.10870099067688
Output for 5.2.17
Object time = 0.16379594802856 Array time = 0.13514685630798
Output for 5.2.16
Object time = 0.16288089752197 Array time = 0.13887810707092
Output for 5.2.15
Object time = 0.17724800109863 Array time = 0.13698601722717
Output for 5.2.14
Object time = 0.17554712295532 Array time = 0.13619613647461
Output for 5.2.13
Object time = 0.17341613769531 Array time = 0.13364005088806
Output for 5.2.12
Object time = 0.1639678478241 Array time = 0.13524794578552
Output for 5.2.11
Object time = 0.15165114402771 Array time = 0.13571715354919
Output for 5.2.10
Object time = 0.14852809906006 Array time = 0.13592386245728
Output for 5.2.9
Object time = 0.16170310974121 Array time = 0.13749504089355
Output for 5.2.8
Object time = 0.15874004364014 Array time = 0.13569498062134
Output for 5.2.7
Object time = 0.19965004920959 Array time = 0.18417501449585
Output for 5.2.6
Object time = 0.14759397506714 Array time = 0.13445210456848
Output for 5.2.5
Object time = 0.15288686752319 Array time = 0.13985204696655
Output for 5.2.4
Object time = 0.16968417167664 Array time = 0.14067506790161
Output for 5.2.3
Object time = 0.15010786056519 Array time = 0.13579607009888
Output for 5.2.2
Object time = 0.13508701324463 Array time = 0.13524007797241
Output for 5.2.1
Object time = 0.15915703773499 Array time = 0.13708710670471
Output for 5.2.0
Object time = 0.17696309089661 Array time = 0.13360095024109
Output for 5.1.6
Object time = 0.18565893173218 Array time = 0.13129305839539
Output for 5.1.5
Object time = 0.15355396270752 Array time = 0.13105893135071
Output for 5.1.4
Object time = 0.16735291481018 Array time = 0.1309871673584
Output for 5.1.3
Object time = 0.17508411407471 Array time = 0.13003301620483
Output for 5.1.2
Object time = 0.16069197654724 Array time = 0.13070011138916
Output for 5.1.1
Object time = 0.14616107940674 Array time = 0.13221216201782
Output for 5.1.0
Object time = 0.18852090835571 Array time = 0.17256999015808
Output for 5.0.5
Object time = 0.19996500015259 Array time = 0.20208287239075
Output for 5.0.4
Object time = 0.19434905052185 Array time = 0.19978094100952
Output for 5.0.3
Object time = 0.19056606292725 Array time = 0.19582796096802
Output for 5.0.2
Object time = 0.19225311279297 Array time = 0.19675183296204
Output for 5.0.1
Object time = 0.19264483451843 Array time = 0.20604991912842
Output for 5.0.0
Object time = 0.21374702453613 Array time = 0.20949292182922
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/ZogHd on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/ZogHd on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/ZogHd on line 8
Process exited with code 255.