3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $tests = 1000000; $max = 5000001; for( $i = 1; $i <= $max; $i += 10000 ) { //create lookup array $array = array_fill( 0, $i, NULL ); //build test indexes $test_indexes = array(); for( $j = 0; $j < $tests; $j++ ) { $test_indexes[] = rand( 0, $i-1 ); } //benchmark array lookups $start = microtime( TRUE ); foreach( $test_indexes as $test_index ) { $value = $array[ $test_index ]; unset( $value ); } $stop = microtime( TRUE ); unset( $array, $test_indexes, $test_index ); printf( "%d,%1.15f\n", $i, $stop - $start ); //time per 1mil lookups unset( $stop, $start ); }
Output for 7.1.0
1,0.020144939422607 10001,0.019789934158325 20001,0.019143104553223 30001,0.020408868789673 40001,0.019572973251343 50001,0.020939826965332 60001,0.020001173019409 70001,0.021380901336670 80001,0.020940065383911 90001,0.022057056427002 100001,0.022546052932739 110001,0.023020029067993 120001,0.023006916046143 130001,0.024392843246460 140001,0.025228977203369 150001,0.027422904968262 160001,0.435303926467896 170001,0.030432939529419 180001,0.028671979904175 190001,0.035130023956299
Process exited with code 137.
Output for 7.0.14
1,0.023149967193604 10001,0.020372867584229 20001,0.020882129669189 30001,0.021239042282104 40001,0.021641016006470 50001,0.022194862365723 60001,0.026218891143799 70001,-0.023375988006592 80001,0.325123071670532 90001,0.025272130966187 100001,0.026428937911987 110001,0.027774095535278 120001,0.029335975646973 130001,0.030813932418823 140001,0.032594919204712 150001,0.034110069274902 160001,-0.035801887512207 170001,0.037508010864258 180001,0.038941860198975 190001,0.040375947952271 200001,0.041728019714355
Process exited with code 137.
Output for 7.0.12
1,0.023683071136475 10001,0.020445823669434 20001,0.020838975906372 30001,0.021283864974976 40001,0.022187948226929 50001,0.022490978240967 60001,0.023143768310547 70001,0.024096965789795 80001,0.024960994720459 90001,0.025768995285034 100001,0.026855945587158 110001,0.049807071685791 120001,0.036455869674683 130001,0.034148931503296 140001,0.035869836807251 150001,0.035743951797485 160001,0.039242029190063 170001,0.039113044738770 180001,0.040462970733643 190001,0.042140007019043 200001,0.043281793594360 210001,0.045423030853271
Process exited with code 137.
Output for 7.0.6
1,0.018617868423462 10001,0.023081064224243 20001,0.024557113647461 30001,0.025294780731201 40001,0.025876998901367 50001,0.026112079620361 60001,0.026223897933960 70001,0.025549888610840 80001,0.021651029586792 90001,0.021714925765991 100001,0.021905899047852 110001,0.022437810897827 120001,0.022515058517456 130001,0.022782087326050 140001,0.023215055465698 150001,0.023663997650146 160001,0.023972988128662 170001,0.024215936660767 180001,0.024825096130371 190001,0.025623083114624 200001,0.025959968566895 210001,0.026675939559937 220001,0.027033805847168 230001,0.027822971343994 240001,0.028650999069214
Process exited with code 137.
Output for 7.0.5
1,0.019310951232910 10001,0.023049116134644 20001,0.024513006210327 30001,0.025320053100586 40001,0.025712013244629 50001,0.025976896286011 60001,0.026298999786377 70001,0.026502132415771 80001,0.026629924774170 90001,0.022062063217163 100001,0.022016048431396 110001,0.022325992584229 120001,0.022637844085693 130001,0.022899866104126 140001,0.023114919662476 150001,0.023452043533325 160001,0.023694038391113 170001,0.024746179580688 180001,0.024813175201416 190001,0.025496959686279 200001,0.026198148727417 210001,0.027987003326416 220001,0.027515888214111 230001,0.027904987335205 240001,0.028194189071655
Process exited with code 137.
Output for 7.0.4
1,0.018934011459351 10001,0.023065090179443 20001,0.024480104446411 30001,0.025449037551880 40001,0.025708913803101 50001,0.025783061981201 60001,0.025583028793335 70001,0.022342920303345 80001,0.021574974060059 90001,0.021815061569214 100001,0.022000074386597 110001,0.022356033325195 120001,0.022452831268311 130001,0.022850990295410 140001,0.023134946823120 150001,0.023552179336548 160001,0.024212121963501 170001,0.024461030960083 180001,0.025199890136719 190001,0.025704145431519 200001,0.025925159454346 210001,0.026885986328125 220001,0.027555942535400 230001,0.027515172958374
Process exited with code 137.
Output for 7.0.3
1,0.018597841262817 10001,0.022974967956543 20001,0.024379968643188 30001,0.025147914886475 40001,0.025613069534302 50001,0.025898218154907 60001,0.021566867828369 70001,0.021275043487549 80001,0.021523952484131 90001,0.021692991256714 100001,0.022059202194214 110001,0.022280931472778 120001,0.022562980651855 130001,0.022998809814453 140001,0.023127079010010 150001,0.023766994476318 160001,0.024008035659790 170001,0.024407148361206 180001,0.024963140487671 190001,0.025500059127808 200001,0.025655031204224 210001,0.026228904724121 220001,0.028286933898926 230001,0.027500152587891 240001,0.029577016830444
Process exited with code 137.
Output for 7.0.2
1,0.018654108047485 10001,0.022449016571045 20001,0.023602008819580 30001,0.024389028549194 40001,0.024607896804810 50001,0.024663209915161 60001,0.025123119354248 70001,0.023293018341064 80001,0.021593093872070 90001,0.021818161010742 100001,0.022041082382202 110001,0.022257089614868 120001,0.022614955902100 130001,0.022881031036377 140001,0.023247003555298 150001,0.023536920547485 160001,0.023965120315552 170001,0.024406194686890 180001,0.025087833404541 190001,0.025267124176025 200001,0.026226997375488 210001,0.026889085769653 220001,0.027368068695068 230001,0.028100013732910 240001,0.028959989547729
Process exited with code 137.
Output for 7.0.1
1,0.019898891448975 10001,0.019099950790405 20001,0.019577026367188 30001,0.020351171493530 40001,0.020633935928345 50001,0.020990848541260 60001,0.021205902099609 70001,0.021407842636108 80001,0.021654844284058 90001,0.021957874298096 100001,0.022224187850952 110001,0.022453069686890 120001,0.022715806961060 130001,0.022989988327026 140001,0.023414850234985 150001,0.023678064346313 160001,0.024230003356934 170001,0.024538993835449 180001,0.024847030639648 190001,0.025789976119995 200001,0.026507854461670 210001,0.026574134826660 220001,0.027354955673218 230001,0.028005838394165 240001,0.029246091842651 250001,0.029459953308105 260001,0.029996871948242 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/3Q4W8 on line 13
Process exited with code 137.
Output for 7.0.0
1,0.018620014190674 10001,0.022395133972168 20001,0.023413896560669 30001,0.023396015167236 40001,0.023959875106812 50001,0.024194002151489 60001,0.024718046188354 70001,0.021923065185547 80001,0.022469997406006 90001,0.023936033248901 100001,0.023684024810791 110001,0.025340080261230 120001,0.026039838790894 130001,0.026372909545898 140001,0.027479171752930 150001,0.029478073120117 160001,0.026409864425659 170001,0.031014919281006 180001,0.030655860900879 190001,0.032860040664673 200001,0.033567905426025 210001,0.033807039260864 220001,0.033663034439087 230001,0.053068876266479
Process exited with code 137.
Output for 5.3.0 - 5.6.28
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/3Q4W8 on line 13
Process exited with code 255.