3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class ArrayTester { const TEST_LOOP_SIZE = 100000; public function go() { $start = microtime(true); for($a = 0; $a<=self::TEST_LOOP_SIZE;++$a) { $test = $this->getTest(); $someVal = $test[$a]; } echo 'Pass by copy: ' . (microtime(true) - $start) . ' sec<br>'; $start = microtime(true); for($a = 0; $a<=self::TEST_LOOP_SIZE;++$a) { $test = &$this->getTestByRef(); $someVal = $test[$a]; } echo 'Pass by reference: ' . (microtime(true) - $start) . ' sec<br>'; } private $_test; private function getTest() { if(!$this->_test) { for($a = 0; $a<=self::TEST_LOOP_SIZE;++$a) { $this->_test[$a]=md5($a); } } return $this->_test; } private $_testByRef; private function &getTestByRef() { if(!$this->_testByRef) { for($a = 0; $a<=self::TEST_LOOP_SIZE;++$a) { $this->_testByRef[$a]=md5($a); } } return $this->_testByRef; } } $tester = new ArrayTester(); $tester->go();
Output for 7.1.0
Pass by copy: 0.04991888999939 sec<br>Pass by reference: 0.044562101364136 sec<br>
Output for 7.0.14
Pass by copy: 0.049978017807007 sec<br>Pass by reference: 0.04465913772583 sec<br>
Output for 7.0.6
Pass by copy: 0.033828020095825 sec<br>Pass by reference: 0.034291982650757 sec<br>
Output for 7.0.5
Pass by copy: 0.050682067871094 sec<br>Pass by reference: 0.040271043777466 sec<br>
Output for 7.0.4
Pass by copy: 0.033591985702515 sec<br>Pass by reference: 0.034031867980957 sec<br>
Output for 7.0.3
Pass by copy: 0.039271831512451 sec<br>Pass by reference: 0.039506912231445 sec<br>
Output for 7.0.2
Pass by copy: 0.041521072387695 sec<br>Pass by reference: 0.044344186782837 sec<br>
Output for 7.0.1
Pass by copy: 0.047719955444336 sec<br>Pass by reference: 0.040728092193604 sec<br>
Output for 7.0.0
Pass by copy: 0.049885034561157 sec<br>Pass by reference: 0.04221510887146 sec<br>
Output for 5.6.28
Pass by copy: 0.088848114013672 sec<br>Pass by reference: 0.070918083190918 sec<br>
Output for 5.6.21
Pass by copy: 0.083274841308594 sec<br>Pass by reference: 0.064220905303955 sec<br>
Output for 5.6.20
Pass by copy: 0.074943065643311 sec<br>Pass by reference: 0.061944007873535 sec<br>
Output for 5.6.19
Pass by copy: 0.074687957763672 sec<br>Pass by reference: 0.062060832977295 sec<br>
Output for 5.6.18
Pass by copy: 0.058811187744141 sec<br>Pass by reference: 0.05938196182251 sec<br>
Output for 5.6.17
Pass by copy: 0.060817956924438 sec<br>Pass by reference: 0.060131788253784 sec<br>
Output for 5.6.16
Pass by copy: 0.081423997879028 sec<br>Pass by reference: 0.064121961593628 sec<br>
Output for 5.6.15
Pass by copy: 0.080930948257446 sec<br>Pass by reference: 0.06475305557251 sec<br>
Output for 5.6.14
Pass by copy: 0.081366062164307 sec<br>Pass by reference: 0.065549850463867 sec<br>
Output for 5.6.13
Pass by copy: 0.080735921859741 sec<br>Pass by reference: 0.063600063323975 sec<br>
Output for 5.6.12
Pass by copy: 0.058780908584595 sec<br>Pass by reference: 0.059315919876099 sec<br>
Output for 5.6.11
Pass by copy: 0.06181001663208 sec<br>Pass by reference: 0.06159496307373 sec<br>
Output for 5.6.10
Pass by copy: 0.08076000213623 sec<br>Pass by reference: 0.064270973205566 sec<br>
Output for 5.6.9
Pass by copy: 0.065777063369751 sec<br>Pass by reference: 0.063133955001831 sec<br>
Output for 5.6.8
Pass by copy: 0.061720848083496 sec<br>Pass by reference: 0.062242031097412 sec<br>
Output for 5.6.7
Pass by copy: 0.049853086471558 sec<br>Pass by reference: 0.050590991973877 sec<br>
Output for 5.5.35
Pass by copy: 0.073860168457031 sec<br>Pass by reference: 0.063920974731445 sec<br>
Output for 5.5.34
Pass by copy: 0.067111968994141 sec<br>Pass by reference: 0.064948081970215 sec<br>
Output for 5.5.33
Pass by copy: 0.062521934509277 sec<br>Pass by reference: 0.063124179840088 sec<br>
Output for 5.5.32
Pass by copy: 0.06883692741394 sec<br>Pass by reference: 0.063863039016724 sec<br>
Output for 5.5.31
Pass by copy: 0.080054998397827 sec<br>Pass by reference: 0.084025144577026 sec<br>
Output for 5.5.30
Pass by copy: 0.077030897140503 sec<br>Pass by reference: 0.065310955047607 sec<br>
Output for 5.5.29
Pass by copy: 0.086553812026978 sec<br>Pass by reference: 0.067876100540161 sec<br>
Output for 5.5.28
Pass by copy: 0.064398050308228 sec<br>Pass by reference: 0.064908981323242 sec<br>
Output for 5.5.27
Pass by copy: 0.086863994598389 sec<br>Pass by reference: 0.067595958709717 sec<br>
Output for 5.5.26
Pass by copy: 0.06722092628479 sec<br>Pass by reference: 0.065580129623413 sec<br>
Output for 5.5.25
Pass by copy: 0.073827028274536 sec<br>Pass by reference: 0.063514947891235 sec<br>
Output for 5.5.24
Pass by copy: 0.077494859695435 sec<br>Pass by reference: 0.065841913223267 sec<br>
Output for 5.4.45
Pass by copy: 0.096978902816772 sec<br>Pass by reference: 0.14211797714233 sec<br>
Output for 5.4.44
Pass by copy: 0.11512112617493 sec<br>Pass by reference: 0.13535213470459 sec<br>
Output for 5.4.43
Pass by copy: 0.1523540019989 sec<br>Pass by reference: 0.13610506057739 sec<br>
Output for 5.4.42
Pass by copy: 0.18764400482178 sec<br>Pass by reference: 0.12353706359863 sec<br>
Output for 5.4.41
Pass by copy: 0.206209897995 sec<br>Pass by reference: 0.14726805686951 sec<br>
Output for 5.4.40
Pass by copy: 0.51262402534485 sec<br>Pass by reference: 0.30799293518066 sec<br>
Output for 5.4.39
Pass by copy: 0.17680406570435 sec<br>Pass by reference: 0.10440993309021 sec<br>
Output for 5.4.38
Pass by copy: 0.3333158493042 sec<br>Pass by reference: 0.19877600669861 sec<br>
Output for 5.4.37
Pass by copy: 0.15987110137939 sec<br>Pass by reference: 0.11206889152527 sec<br>
Output for 5.4.36
Pass by copy: 0.18667507171631 sec<br>Pass by reference: 0.12653303146362 sec<br>
Output for 5.4.35
Pass by copy: 0.14882183074951 sec<br>Pass by reference: 0.19939994812012 sec<br>
Output for 5.4.34
Pass by copy: 0.11526393890381 sec<br>Pass by reference: 0.10406422615051 sec<br>
Output for 5.4.32
Pass by copy: 0.070854902267456 sec<br>Pass by reference: 0.069774866104126 sec<br>
Output for 5.4.31
Pass by copy: 0.080132007598877 sec<br>Pass by reference: 0.07297420501709 sec<br>
Output for 5.4.30
Pass by copy: 0.073626041412354 sec<br>Pass by reference: 0.07201099395752 sec<br>
Output for 5.4.29
Pass by copy: 0.070489883422852 sec<br>Pass by reference: 0.068030834197998 sec<br>
Output for 5.4.28
Pass by copy: 0.077628135681152 sec<br>Pass by reference: 0.071892023086548 sec<br>
Output for 5.4.27
Pass by copy: 0.075125932693481 sec<br>Pass by reference: 0.071025133132935 sec<br>
Output for 5.4.26
Pass by copy: 0.07517409324646 sec<br>Pass by reference: 0.070513010025024 sec<br>
Output for 5.4.25
Pass by copy: 0.076314210891724 sec<br>Pass by reference: 0.071928024291992 sec<br>
Output for 5.4.24
Pass by copy: 0.072828054428101 sec<br>Pass by reference: 0.074307203292847 sec<br>
Output for 5.4.23
Pass by copy: 0.07648491859436 sec<br>Pass by reference: 0.075218915939331 sec<br>
Output for 5.4.22
Pass by copy: 0.069801092147827 sec<br>Pass by reference: 0.070209980010986 sec<br>
Output for 5.4.21
Pass by copy: 0.074975967407227 sec<br>Pass by reference: 0.071731090545654 sec<br>
Output for 5.4.20
Pass by copy: 0.073939085006714 sec<br>Pass by reference: 0.07007098197937 sec<br>
Output for 5.4.19
Pass by copy: 0.077099800109863 sec<br>Pass by reference: 0.078563928604126 sec<br>
Output for 5.4.18
Pass by copy: 0.079143047332764 sec<br>Pass by reference: 0.073881149291992 sec<br>
Output for 5.4.17
Pass by copy: 0.10672998428345 sec<br>Pass by reference: 0.093254804611206 sec<br>
Output for 5.4.16
Pass by copy: 0.087160110473633 sec<br>Pass by reference: 0.090291023254395 sec<br>
Output for 5.4.15
Pass by copy: 0.12455821037292 sec<br>Pass by reference: 0.10650897026062 sec<br>
Output for 5.4.14
Pass by copy: 0.088159084320068 sec<br>Pass by reference: 0.087605953216553 sec<br>
Output for 5.4.13
Pass by copy: 0.1081109046936 sec<br>Pass by reference: 0.084873914718628 sec<br>
Output for 5.4.12
Pass by copy: 0.098875045776367 sec<br>Pass by reference: 0.073544979095459 sec<br>
Output for 5.4.11
Pass by copy: 0.086585998535156 sec<br>Pass by reference: 0.072633028030396 sec<br>
Output for 5.4.10
Pass by copy: 0.075582981109619 sec<br>Pass by reference: 0.071966171264648 sec<br>
Output for 5.4.9
Pass by copy: 0.07765007019043 sec<br>Pass by reference: 0.08697509765625 sec<br>
Output for 5.4.8
Pass by copy: 0.073283910751343 sec<br>Pass by reference: 0.083747863769531 sec<br>
Output for 5.4.7
Pass by copy: 0.073963165283203 sec<br>Pass by reference: 0.072722196578979 sec<br>
Output for 5.4.6
Pass by copy: 0.09480094909668 sec<br>Pass by reference: 0.084666967391968 sec<br>
Output for 5.4.5
Pass by copy: 0.074243068695068 sec<br>Pass by reference: 0.075947999954224 sec<br>
Output for 5.4.4
Pass by copy: 0.077273845672607 sec<br>Pass by reference: 0.078637838363647 sec<br>
Output for 5.4.3
Pass by copy: 0.079482078552246 sec<br>Pass by reference: 0.077434062957764 sec<br>
Output for 5.4.2
Pass by copy: 0.081450939178467 sec<br>Pass by reference: 0.078623056411743 sec<br>
Output for 5.4.1
Pass by copy: 0.077461004257202 sec<br>Pass by reference: 0.075028896331787 sec<br>
Output for 5.4.0
Pass by copy: 0.075824022293091 sec<br>Pass by reference: 0.076515913009644 sec<br>
Output for 5.3.29
Pass by copy: 0.099736928939819 sec<br>Pass by reference: 0.092132091522217 sec<br>
Output for 5.3.28
Pass by copy: 0.098198890686035 sec<br>Pass by reference: 0.095800876617432 sec<br>
Output for 5.3.27
Pass by copy: 0.11139893531799 sec<br>Pass by reference: 0.10425209999084 sec<br>
Output for 5.3.26
Pass by copy: 0.11549305915833 sec<br>Pass by reference: 0.12937498092651 sec<br>
Output for 5.3.25
Pass by copy: 0.10723209381104 sec<br>Pass by reference: 0.12151980400085 sec<br>
Output for 5.3.24
Pass by copy: 0.13164281845093 sec<br>Pass by reference: 0.11475801467896 sec<br>
Output for 5.3.23
Pass by copy: 0.16306495666504 sec<br>Pass by reference: 0.1212739944458 sec<br>
Output for 5.3.22
Pass by copy: 0.10296583175659 sec<br>Pass by reference: 0.099724054336548 sec<br>
Output for 5.3.21
Pass by copy: 0.10641193389893 sec<br>Pass by reference: 0.10166192054749 sec<br>
Output for 5.3.20
Pass by copy: 0.10307621955872 sec<br>Pass by reference: 0.095887184143066 sec<br>
Output for 5.3.19
Pass by copy: 0.11294913291931 sec<br>Pass by reference: 0.099382162094116 sec<br>
Output for 5.3.18
Pass by copy: 0.096308946609497 sec<br>Pass by reference: 0.094567060470581 sec<br>
Output for 5.3.17
Pass by copy: 0.10514116287231 sec<br>Pass by reference: 0.10718607902527 sec<br>
Output for 5.3.16
Pass by copy: 0.11192607879639 sec<br>Pass by reference: 0.13172793388367 sec<br>
Output for 5.3.15
Pass by copy: 0.097675085067749 sec<br>Pass by reference: 0.092591047286987 sec<br>
Output for 5.3.14
Pass by copy: 0.10535001754761 sec<br>Pass by reference: 0.10064291954041 sec<br>
Output for 5.3.13
Pass by copy: 0.13680005073547 sec<br>Pass by reference: 0.10937190055847 sec<br>
Output for 5.3.12
Pass by copy: 0.10223007202148 sec<br>Pass by reference: 0.10064005851746 sec<br>
Output for 5.3.11
Pass by copy: 0.098711967468262 sec<br>Pass by reference: 0.096206903457642 sec<br>
Output for 5.3.10
Pass by copy: 0.10053896903992 sec<br>Pass by reference: 0.11670184135437 sec<br>
Output for 5.3.9
Pass by copy: 0.12378907203674 sec<br>Pass by reference: 0.10537600517273 sec<br>
Output for 5.3.8
Pass by copy: 0.10343599319458 sec<br>Pass by reference: 0.10669708251953 sec<br>
Output for 5.3.7
Pass by copy: 0.12744808197021 sec<br>Pass by reference: 0.12819910049438 sec<br>
Output for 5.3.6
Pass by copy: 0.10597014427185 sec<br>Pass by reference: 0.1116042137146 sec<br>
Output for 5.3.5
Pass by copy: 0.10768103599548 sec<br>Pass by reference: 0.13648200035095 sec<br>
Output for 5.3.4
Pass by copy: 0.17097496986389 sec<br>Pass by reference: 0.10413599014282 sec<br>
Output for 5.3.3
Pass by copy: 0.11791205406189 sec<br>Pass by reference: 0.11854791641235 sec<br>
Output for 5.3.2
Pass by copy: 0.15830087661743 sec<br>Pass by reference: 0.21787095069885 sec<br>
Output for 5.3.1
Pass by copy: 0.1068971157074 sec<br>Pass by reference: 0.13094091415405 sec<br>
Output for 5.3.0
Pass by copy: 0.11663794517517 sec<br>Pass by reference: 0.13054704666138 sec<br>
Output for 5.2.17
Pass by copy: 0.13839221000671 sec<br>Pass by reference: 0.11508297920227 sec<br>
Output for 5.2.16
Pass by copy: 0.17489004135132 sec<br>Pass by reference: 0.12905311584473 sec<br>
Output for 5.2.15
Pass by copy: 0.14069294929504 sec<br>Pass by reference: 0.11675000190735 sec<br>
Output for 5.2.14
Pass by copy: 0.12431788444519 sec<br>Pass by reference: 0.16162014007568 sec<br>
Output for 5.2.13
Pass by copy: 0.11235594749451 sec<br>Pass by reference: 0.10619282722473 sec<br>
Output for 5.2.12
Pass by copy: 0.11447095870972 sec<br>Pass by reference: 0.11836099624634 sec<br>
Output for 5.2.11
Pass by copy: 0.11066198348999 sec<br>Pass by reference: 0.12437605857849 sec<br>
Output for 5.2.10
Pass by copy: 0.12431907653809 sec<br>Pass by reference: 0.12649512290955 sec<br>
Output for 5.2.9
Pass by copy: 0.14652705192566 sec<br>Pass by reference: 0.16328191757202 sec<br>
Output for 5.2.8
Pass by copy: 0.12401485443115 sec<br>Pass by reference: 0.13148403167725 sec<br>
Output for 5.2.7
Pass by copy: 0.11246109008789 sec<br>Pass by reference: 0.10812401771545 sec<br>
Output for 5.2.6
Pass by copy: 0.11700010299683 sec<br>Pass by reference: 0.12587094306946 sec<br>
Output for 5.2.5
Pass by copy: 0.1307909488678 sec<br>Pass by reference: 0.14254403114319 sec<br>
Output for 5.2.4
Pass by copy: 0.14145803451538 sec<br>Pass by reference: 0.13041186332703 sec<br>
Output for 5.2.3
Pass by copy: 0.13657999038696 sec<br>Pass by reference: 0.12108111381531 sec<br>
Output for 5.2.2
Pass by copy: 0.28431105613708 sec<br>Pass by reference: 0.27748703956604 sec<br>
Output for 5.2.1
Pass by copy: 0.24923992156982 sec<br>Pass by reference: 0.26390099525452 sec<br>
Output for 5.2.0
Pass by copy: 0.26364517211914 sec<br>Pass by reference: 0.26317501068115 sec<br>
Output for 5.1.6
Pass by copy: 0.25722289085388 sec<br>Pass by reference: 0.2603919506073 sec<br>
Output for 5.1.5
Pass by copy: 0.27000713348389 sec<br>Pass by reference: 0.261234998703 sec<br>
Output for 5.1.4
Pass by copy: 0.30423188209534 sec<br>Pass by reference: 0.29819393157959 sec<br>
Output for 5.1.3
Pass by copy: 0.33031392097473 sec<br>Pass by reference: 0.38947296142578 sec<br>
Output for 5.1.2
Pass by copy: 0.43605208396912 sec<br>Pass by reference: 0.41849803924561 sec<br>
Output for 5.1.1
Pass by copy: 0.31503701210022 sec<br>Pass by reference: 0.394446849823 sec<br>
Output for 5.1.0
Pass by copy: 0.31799507141113 sec<br>Pass by reference: 0.28793406486511 sec<br>
Output for 5.0.5
Pass by copy: 0.31881809234619 sec<br>Pass by reference: 0.41145205497742 sec<br>
Output for 5.0.4
Pass by copy: 0.41529893875122 sec<br>Pass by reference: 0.38337898254395 sec<br>
Output for 5.0.3
Pass by copy: 0.42423415184021 sec<br>Pass by reference: 0.39464402198792 sec<br>
Output for 5.0.2
Pass by copy: 0.37261486053467 sec<br>Pass by reference: 0.33580899238586 sec<br>
Output for 5.0.1
Pass by copy: 0.32206702232361 sec<br>Pass by reference: 0.35164499282837 sec<br>
Output for 5.0.0
Pass by copy: 0.4708240032196 sec<br>Pass by reference: 0.50428295135498 sec<br>
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/sRRL8 on line 4
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_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/sRRL8 on line 4
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/sRRL8 on line 4
Process exited with code 255.