3v4l.org

run code in 300+ PHP versions simultaneously
<?php // needed to cope with a million entry array ini_set('memory_limit', '512M'); $limit = 100000; $text[] = "Now is the time"; $text[] = "for all good men"; $text[] = "to come to the aid"; $text[] = "of their country."; $text2['part1'] = "Now is the time"; $text2['part2'] = "for all good men"; $text2['part3'] = "to come to the aid"; $text2['part4'] = "of their country."; $bigArray = fillArray($limit); $max=count($bigArray); ####################################################### $start = microtime(TRUE); for($i=0; $i<$max; $i++) { $bigArray[$i] = $text[0]; $bigArray[$i] .= ' '; $bigArray[$i] .= $text[1]; $bigArray[$i] .= ' '; $bigArray[$i] .= $text[2]; $bigArray[$i] .= ' '; $bigArray[$i] .= $text[3]; } $results['dotequal']['time'] = microtime(TRUE) - $start; $results['dotequal']['name'] = 'Dot Equals'; ####################################################### $start = microtime(TRUE); for($i=0; $i<$max; $i++) { $bigArray[$i] = $text[0].' '.$text[1].' '.$text[2].' '.$text[3]; } $results['concat']['time'] = microtime(TRUE) - $start; $results['concat']['name'] = 'Dot Concatenation'; ####################################################### $start = microtime(TRUE); for($i=0; $i<$max; $i++) { $bigArray[$i] = "$text[0] $text[1] $text[2] $text[3]"; } $results['replace']['time'] = microtime(TRUE) - $start; $results['replace']['name'] = 'In-string Replacement'; ####################################################### $start = microtime(TRUE); for($i=0; $i<$max; $i++) { $bigArray[$i] = "{$text2['part1']} {$text2['part2']} {$text2['part3']} {$text2['part4']}"; } $results['replace2']['time'] = microtime(TRUE) - $start; $results['replace2']['name'] = 'Complex In-string Replacement'; ####################################################### $start = microtime(TRUE); for($i=0; $i<$max; $i++) { $bigArray[$i] = sprintf('%s %s %s %s', $text[0], $text[1], $text[2], $text[3]); } $results['sprintf']['time'] = microtime(TRUE) - $start; $results['sprintf']['name'] = 'Function: sprintf()'; ####################################################### $start = microtime(TRUE); for($i=0; $i<$max; $i++) { $bigArray[$i] = implode(' ', $text); } $results['implode']['time'] = microtime(TRUE) - $start; $results['implode']['name'] = 'Function: implode()'; ####################################################### foreach($results AS $test) { echo $test['name']." -- ".sprintf("%01.6f", $test['time'])."\n"; } ####################################################### function fillArray($limit) { // build huge array for($i=0; $i<$limit; $i++) { $array[] = $i; } return $array; } ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.4.00.0200.18268.33
7.3.120.0260.22868.61
7.3.110.0400.21868.43
7.3.100.0300.23168.78
7.3.90.0260.14568.85
7.3.80.0200.17468.69
7.3.70.0370.19768.68
7.3.60.0170.14568.48
7.3.50.0100.17468.32
7.3.40.0270.14568.61
7.3.30.0330.13868.25
7.3.20.0130.16070.62
7.3.10.1460.14670.46
7.3.00.0440.14570.41
7.2.250.0330.23668.74
7.2.240.0330.23268.78
7.2.230.0260.17968.74
7.2.220.0430.16568.95
7.2.210.0260.19768.85
7.2.200.0230.17668.53
7.2.190.0200.18268.81
7.2.180.0260.19568.92
7.2.170.0340.15568.90
7.2.160.0300.14168.84
7.2.150.0360.15870.88
7.2.140.0170.14070.76
7.2.130.0330.18070.81
7.2.120.0190.17870.73
7.2.110.0150.16370.74
7.2.100.0260.14770.90
7.2.90.0200.16270.68
7.2.80.0150.19770.99
7.2.70.0180.15770.90
7.2.60.0200.15770.80
7.2.50.0260.15970.89
7.2.40.0180.16270.86
7.2.30.0200.16670.87
7.2.20.0180.14970.88
7.2.10.0200.15570.90
7.2.00.0120.17270.79
7.1.330.0230.21469.98
7.1.320.0130.19669.65
7.1.310.0070.20669.75
7.1.300.0200.19169.61
7.1.290.0070.17869.79
7.1.280.0130.20369.99
7.1.270.0230.17669.79
7.1.260.0200.20669.88
7.1.250.0250.19869.87
7.1.240.0100.20169.66
7.1.230.0170.21369.92
7.1.220.0230.24069.69
7.1.210.0170.24469.91
7.1.200.0230.25569.82
7.1.190.0360.20269.86
7.1.180.0130.19669.66
7.1.170.0200.23169.53
7.1.160.0300.20669.80
7.1.150.0200.17469.76
7.1.140.0170.19169.80
7.1.130.0230.24169.94
7.1.120.3280.19369.80
7.1.110.0070.21769.86
7.1.100.1020.19569.96
7.1.90.0100.20169.69
7.1.80.0160.18969.75
7.1.70.0200.15170.32
7.1.60.0180.16970.61
7.1.50.0520.15570.33
7.1.40.0260.18669.77
7.1.30.0180.21469.91
7.1.20.0290.20669.73
7.1.10.0160.21069.83
7.1.00.0150.20372.96
7.0.330.0270.23669.32
7.0.320.0200.20169.51
7.0.310.0200.18969.50
7.0.300.0300.19569.41
7.0.290.0200.21969.19
7.0.280.0170.20569.21
7.0.270.0270.21669.52
7.0.260.0130.20269.42
7.0.250.0130.27269.43
7.0.240.0100.18869.61
7.0.230.0160.21469.65
7.0.220.0160.20969.28
7.0.210.0260.20869.40
7.0.200.0290.16470.04
7.0.190.0140.19769.21
7.0.180.0260.19569.54
7.0.170.0180.21869.54
7.0.160.0200.21669.58
7.0.150.0370.18769.57
7.0.140.0230.20872.74
7.0.130.0240.19969.43
7.0.120.0230.18669.47
7.0.110.0200.19569.59
7.0.100.0370.22669.38
7.0.90.0200.20869.56
7.0.80.0260.20269.48
7.0.70.0140.21369.24
7.0.60.0230.18871.57
7.0.50.0250.20470.48
7.0.40.0140.19421.72
7.0.30.0370.17921.51
7.0.20.0320.16321.70
7.0.10.0100.21221.74
7.0.00.0180.20221.53
5.6.400.0230.41354.09
5.6.390.0200.38754.05
5.6.380.0230.44754.13
5.6.370.0170.41054.06
5.6.360.0230.38254.15
5.6.350.0330.38654.23
5.6.340.0270.43553.93
5.6.330.0230.36953.85
5.6.320.0230.36654.39
5.6.310.0330.38553.91
5.6.300.0430.37653.97
5.6.290.0270.37354.36
5.6.280.0230.37157.30
5.6.270.0390.36954.16
5.6.260.0430.41854.19
5.6.250.0370.40353.65
5.6.240.0390.37154.26
5.6.230.0300.42254.07
5.6.220.0330.36854.17
5.6.210.0280.33357.06
5.6.200.0260.31655.81
5.6.190.0180.34056.96
5.6.180.0290.29657.22
5.6.170.0320.32256.99
5.6.160.0150.31756.90
5.6.150.0320.32755.97
5.6.140.0150.31356.09
5.6.130.0260.33755.92
5.6.120.0320.33157.41
5.6.110.0230.33157.34
5.6.100.0310.33957.37
5.6.90.0250.33157.25
5.6.80.0260.35157.00
5.6.70.0210.36953.82
5.6.60.0400.36953.89
5.6.50.0300.40953.77
5.6.40.0330.42153.84
5.6.30.0230.40353.77
5.6.20.0270.38054.12
5.6.10.0130.38954.13
5.6.00.0340.37553.87
5.5.380.0200.41653.93
5.5.370.0320.38054.20
5.5.360.0300.37653.91
5.5.350.0300.34257.11
5.5.340.0270.34155.77
5.5.330.0270.32256.78
5.5.320.0420.34656.77
5.5.310.0230.34157.08
5.5.300.0270.33655.60
5.5.290.0250.35955.88
5.5.280.0320.29957.27
5.5.270.0280.34257.12
5.5.260.0200.33057.17
5.5.250.0230.34757.15
5.5.240.0280.29256.76
5.5.230.0430.38053.95
5.5.220.0340.37853.97
5.5.210.0200.40154.28
5.5.200.0360.36853.93
5.5.190.0220.37754.15
5.5.180.0260.39753.96
5.5.170.0300.39354.29
5.5.160.0330.38054.05
5.5.150.0410.38453.75
5.5.140.0420.39254.36
5.5.130.0360.41753.74
5.5.120.0270.38053.96
5.5.110.0290.39654.16
5.5.100.0270.38354.04
5.5.90.0400.40653.97
5.5.80.0250.41853.68
5.5.70.0370.37654.12
5.5.60.0160.39553.94
5.5.50.0230.38254.09
5.5.40.0130.43754.31
5.5.30.0270.40753.71
5.5.20.0610.44254.14
5.5.10.0230.46553.84
5.5.00.0270.42754.21
5.4.450.0760.39654.86
5.4.440.0700.39754.79
5.4.430.0590.38054.69
5.4.420.0620.42154.76
5.4.410.0620.39254.74
5.4.400.0450.37854.48
5.4.390.0450.39454.52
5.4.380.0350.48954.47
5.4.370.0200.34254.44
5.4.360.0280.37154.44
5.4.350.0310.42651.15
5.4.340.0260.35651.06
5.4.330.0070.38150.60
5.4.320.0350.39251.27
5.4.310.0250.34751.25
5.4.300.0220.33051.41
5.4.290.0230.33551.43
5.4.280.0150.34051.44
5.4.270.0170.35651.46
5.4.260.0240.35651.32
5.4.250.0250.32351.42
5.4.240.0210.33851.40
5.4.230.0210.33051.30
5.4.220.0230.34351.26
5.4.210.0250.35851.33
5.4.200.0200.34651.45
5.4.190.0240.33251.23
5.4.180.0240.34851.30
5.4.170.0240.34551.19
5.4.160.0220.33851.44
5.4.150.0310.36351.26
5.4.140.0240.33651.22
5.4.130.0180.39351.28
5.4.120.0160.35051.33
5.4.110.0160.33451.02
5.4.100.0290.35451.19
5.4.90.0190.37551.18
5.4.80.0160.37151.26
5.4.70.0230.35451.15
5.4.60.0180.37751.25
5.4.50.0240.37251.26
5.4.40.0290.34351.03
5.4.30.0230.36951.16
5.4.20.0210.35951.10
5.4.10.0370.32551.00
5.4.00.0210.37150.84
5.3.290.0190.46550.52
5.3.280.0210.38750.42
5.3.270.0170.39350.37
5.3.260.0230.39950.47
5.3.250.0240.39550.47
5.3.240.0240.36450.34
5.3.230.0220.44050.44
5.3.220.0180.38050.21
5.3.210.0300.39950.38
5.3.200.0200.42450.37
5.3.190.0210.41250.43
5.3.180.0170.44050.46
5.3.170.0220.41350.46
5.3.160.0280.40450.47
5.3.150.0210.36050.47
5.3.140.0190.40350.44
5.3.130.0210.40450.45
5.3.120.0240.38850.37
5.3.110.0230.37550.45
5.3.100.0200.41250.17
5.3.90.0320.37150.16
5.3.80.0260.39850.06
5.3.70.0210.41549.94
5.3.60.0150.40750.05
5.3.50.0230.41250.04
5.3.40.0200.42850.06
5.3.30.0200.38949.89
5.3.20.0260.40949.93
5.3.10.0220.39449.81
5.3.00.0240.36949.81
5.2.170.0150.34147.22
5.2.160.0150.32747.22
5.2.150.0220.32847.21
5.2.140.0160.34047.21
5.2.130.0210.33047.17
5.2.120.0200.33647.18
5.2.110.0210.32347.18
5.2.100.0140.32947.18
5.2.90.0140.36247.18
5.2.80.0160.34447.16
5.2.70.0120.33647.16
5.2.60.0110.33747.12
5.2.50.0210.34547.22
5.2.40.0160.34547.20
5.2.30.0150.34846.91
5.2.20.0140.36746.91
5.2.10.0160.33646.81
5.2.00.0120.36346.93
5.1.60.0180.41551.78
5.1.50.0140.42751.77
5.1.40.0160.44351.76
5.1.30.0190.45752.11
5.1.20.0220.41752.13
5.1.10.0190.41151.86
5.1.00.0220.40451.86
5.0.50.0230.67250.35
5.0.40.0120.69150.21
5.0.30.0200.68450.29
5.0.20.0230.67550.00
5.0.10.0120.67449.97
5.0.00.0140.67649.97
4.4.90.0140.69739.21
4.4.80.0200.69139.19
4.4.70.0080.69239.18
4.4.60.0210.71239.19
4.4.50.0210.67039.20
4.4.40.0210.70939.19
4.4.30.0100.72139.19
4.4.20.0140.70739.25
4.4.10.0130.70139.25
4.4.00.0200.71739.22
4.3.110.0190.68539.13
4.3.100.0140.67339.03
4.3.90.0160.68639.13
4.3.80.0100.71439.07
4.3.70.0200.71339.00
4.3.60.0280.69839.13
4.3.50.0230.70339.00
4.3.40.0230.72938.96
4.3.30.0290.99337.89
4.3.20.0150.73737.87
4.3.10.0100.75937.82
4.3.00.0431.02738.91

preferences:
35.3 ms | 401 KiB | 5 Q