3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string1 = 'aaaaaaaaaaaaaaaaaaaa'; $string2 = 'bbbbbbbbbbbbbbbbbbbb'; $string3 = 'cccccccccccccccccccc'; $string4 = 'dddddddddddddddddddd'; $string5 = 'eeeeeeeeeeeeeeeeeeee'; $results = array(); $time1 = microtime(true); for ($i = 0; $i<1000000; $i++) { $concatTest1 = $string1 . $string2 . $string3 . $string4 . $string5; } unset($i); $time2 = microtime(true); $testDuration1 = $time2 - $time1; $results['Default String Concatenation $a . $b'] = $testDuration1; $time3 = microtime(true); for ($i = 0; $i<1000000; $i++) { $concatTest2 = "{$string1}{$string2}{$string3}{$string4}{$string5}"; } unset($i); $time4 = microtime(true); $testDuration2 = $time4 - $time3; $results['Double Quote Inline-String Concatenation {$a}{$b}'] = $testDuration2; $time5 = microtime(true); for ($i = 0; $i<1000000; $i++) { $concatTest3 = implode('', array( $string1, $string2, $string3, $string4, $string5 )); } unset($i); $time6 = microtime(true); $testDuration3 = $time6 - $time5; $results['Array Implode String Concatenation $a . $b'] = $testDuration3; $time7 = microtime(true); for ($i = 0; $i<1000000; $i++) { $concatTest4 = sprintf('%s%s%s%s%s', array( $string1, $string2, $string3, $string4, $string5 )); } unset($i); $time8 = microtime(true); $testDuration4 = $time8 - $time7; $results['Sprintf String Concatenation sprintf(%s%s, array($a, $b))'] = $testDuration4; $finalResults = sort($results); var_dump($finalResults);

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.10.0070.72214.85
7.4.00.0030.76114.76
7.3.130.0070.75614.66
7.3.120.0130.55014.75
7.3.110.0070.72214.79
7.3.100.0070.56014.67
7.3.90.0070.75114.99
7.3.80.0100.64814.88
7.3.70.0030.55114.74
7.3.60.0070.61514.50
7.3.50.0000.56514.64
7.3.40.0090.57114.88
7.3.30.0070.68114.49
7.3.20.0000.73616.82
7.3.10.0100.68416.60
7.3.00.0000.57816.59
7.2.260.0070.87515.19
7.2.250.0100.67314.80
7.2.240.0100.80515.07
7.2.230.0070.84615.16
7.2.220.0030.81215.21
7.2.210.0130.83915.04
7.2.200.0030.81715.04
7.2.190.0070.84715.07
7.2.180.0100.75915.13
7.2.170.0100.85615.08
7.2.160.0000.62915.10
7.2.150.0070.64216.95
7.2.140.0070.82916.90
7.2.130.0000.68616.89
7.2.120.0030.85416.98
7.2.110.0130.82816.96
7.2.100.0030.87016.76
7.2.90.0070.69417.02
7.2.80.0100.84317.00
7.2.70.0070.67116.73
7.2.60.0100.83416.80
7.2.50.0030.79316.98
7.2.40.0070.73816.82
7.2.30.0030.74016.91
7.2.20.0030.78616.78
7.2.10.0000.70616.78
7.2.00.0030.73716.66
7.1.330.0070.93715.69
7.1.320.0070.97015.95
7.1.310.0030.92315.92
7.1.300.0070.87215.82
7.1.290.0150.83215.52
7.1.280.0030.95615.84
7.1.270.0070.92515.75
7.1.260.0070.95215.75
7.1.250.0100.93915.84
7.1.240.0080.80815.63
7.1.230.0030.96215.87
7.1.220.0030.79015.79
7.1.210.0170.86315.84
7.1.200.0130.94315.91
7.1.190.0030.80215.73
7.1.180.0070.93915.70
7.1.170.0130.90415.71
7.1.160.0030.88415.87
7.1.150.0030.91815.69
7.1.140.0130.82615.61
7.1.130.0070.97215.87
7.1.120.0030.77815.82
7.1.110.0030.77715.79
7.1.100.0000.96515.93
7.1.90.0000.98215.87
7.1.80.0070.79615.79
7.1.70.0130.76615.71
7.1.60.0070.97815.86
7.1.50.0070.96215.82
7.1.40.0070.77615.68
7.1.30.0100.75515.52
7.1.20.0000.88515.70
7.1.10.0000.97515.93
7.1.00.0070.92015.64
7.0.330.0100.77715.35
7.0.320.0130.95915.49
7.0.310.0030.94715.22
7.0.300.0030.98315.45
7.0.290.0070.86915.41
7.0.280.0100.95015.42
7.0.270.0000.85315.51
7.0.260.0070.95915.45
7.0.250.0070.93515.19
7.0.240.0070.96315.41
7.0.230.0070.95115.57
7.0.220.0070.77115.48
7.0.210.0001.00115.56
7.0.200.0030.80415.42
7.0.190.0030.91815.51
7.0.180.0070.93415.46
7.0.170.0000.78115.36
7.0.160.0030.90715.43
7.0.150.0030.80415.18
7.0.140.0070.92815.32
7.0.130.0000.81715.24
7.0.120.0070.93815.46
7.0.110.0070.94215.56
7.0.100.0070.78015.19
7.0.90.0030.77215.14
7.0.80.0070.97215.24
7.0.70.0070.79815.39
7.0.60.0030.96215.32
7.0.50.0030.97915.40
7.0.40.0100.79913.48
7.0.30.0170.90313.37
7.0.20.0030.96313.40
7.0.10.0070.79213.34
7.0.00.0000.94413.59
5.6.400.0071.48814.84
5.6.390.0021.70814.86
5.6.380.0101.65314.53
5.6.370.0031.52414.79
5.6.360.0031.73214.69
5.6.350.0031.46014.50
5.6.340.0091.59614.36
5.6.330.0071.75114.43
5.6.320.0001.65414.34
5.6.310.0071.70914.20
5.6.300.0081.52214.46
5.6.290.0031.58614.32
5.6.280.0001.62414.63
5.6.270.0101.77214.65
5.6.260.0101.79914.43
5.6.250.0001.60614.51
5.6.240.0131.65314.54
5.6.230.0031.40814.15
5.6.220.0101.68114.58
5.6.210.0071.72214.40
5.6.200.0031.39414.66
5.6.190.0031.69114.56
5.6.180.0071.54214.51
5.6.170.0031.65414.39
5.6.160.0031.55714.35
5.6.150.0031.61514.39
5.6.140.0031.76714.36
5.6.130.0031.59814.25
5.6.120.0071.71614.47
5.6.110.0081.44214.52
5.6.100.0071.55114.52
5.6.90.0101.70214.39
5.6.80.0071.55214.63
5.6.70.0001.72714.45
5.6.60.0031.37714.43
5.6.50.0071.47314.56
5.6.40.0031.45114.30
5.6.30.0071.70714.24
5.6.20.0071.76514.07
5.6.10.0101.76914.30
5.6.00.0071.73614.43
5.5.380.0071.71114.48
5.5.370.0101.74714.49
5.5.360.0001.62714.50
5.5.350.0031.61214.35
5.5.340.0131.65314.40
5.5.330.0071.56914.60
5.5.320.0031.64114.39
5.5.310.0031.68214.45
5.5.300.0101.40514.56
5.5.290.0071.62714.59
5.5.280.0031.74914.45
5.5.270.0071.68814.33
5.5.260.0131.70514.50
5.5.250.0031.51214.45
5.5.240.0071.64114.09
5.5.230.0101.59214.26
5.5.220.0101.71214.50
5.5.210.0071.69514.49
5.5.200.0031.47114.09
5.5.190.0131.76614.14
5.5.180.0031.75614.39
5.5.170.0101.73814.17
5.5.160.0101.73214.55
5.5.150.0101.69614.30
5.5.140.0091.40713.95
5.5.130.0101.59914.52
5.5.120.0071.70014.50
5.5.110.0071.55714.41
5.5.100.0031.40414.56
5.5.90.0101.76114.37
5.5.80.0031.75914.53
5.5.70.0031.48014.42
5.5.60.0031.45214.17
5.5.50.0071.63314.13
5.5.40.0101.38814.25
5.5.30.0031.68414.07
5.5.20.0071.61814.37
5.5.10.0071.66314.49
5.5.00.0071.67014.17
5.4.450.0071.77512.58
5.4.440.0031.62612.58
5.4.430.0071.49312.58
5.4.420.0031.49712.58
5.4.410.0101.76012.58
5.4.400.0001.61512.58
5.4.390.0001.70212.58
5.4.380.0071.46312.58
5.4.370.0031.47912.58
5.4.360.0071.74412.58
5.4.350.0001.46012.58
5.4.340.0071.71112.58
5.4.330.0101.40412.58
5.4.320.0071.69812.58
5.4.310.0101.49412.58
5.4.300.0001.70612.58
5.4.290.0071.73012.58
5.4.280.0001.76612.58
5.4.270.0071.68812.58
5.4.260.0031.83312.58
5.4.250.0031.64112.58
5.4.240.0001.46812.58
5.4.230.0071.71012.58
5.4.220.0001.55612.58
5.4.210.0001.75012.58
5.4.200.0001.72912.58
5.4.190.0201.56315.79
5.4.180.0151.35515.71
5.4.170.0181.06715.66
5.4.160.0171.26315.88
5.4.150.0051.30115.83
5.4.140.0201.08714.42
5.4.130.0081.56914.43
5.4.120.0101.47114.51
5.4.110.0031.24414.49
5.4.100.0081.44514.48
5.4.90.0101.47414.39
5.4.80.0121.39214.48
5.4.70.0101.41514.39
5.4.60.0081.46914.40
5.4.50.0101.44014.42
5.4.40.0151.43714.38
5.4.30.0051.49314.46
5.4.20.0131.23914.48
5.4.10.0121.45714.46
5.4.00.0131.40014.08
5.3.290.0071.79312.58
5.3.280.0071.79812.58
5.3.270.0101.33713.42
5.3.260.0101.54813.49
5.3.250.0101.57213.49
5.3.240.0081.73813.48
5.3.230.0181.43513.48
5.3.220.0121.61713.47
5.3.210.0051.56213.42
5.3.200.0101.45013.46
5.3.190.0081.40913.46
5.3.180.0101.56113.46
5.3.170.0131.49413.47
5.3.160.0101.39513.42
5.3.150.0051.52113.46
5.3.140.0081.50013.47
5.3.130.0101.55113.47
5.3.120.0051.59313.45
5.3.110.0071.56113.45
5.3.100.0131.55413.12
5.3.90.0051.56413.17
5.3.80.0131.42813.15
5.3.70.0051.37213.10
5.3.60.0021.52813.14
5.3.50.0071.48113.13
5.3.40.0101.56213.13
5.3.30.0081.43513.09
5.3.20.0151.48512.99
5.3.10.0121.51112.97
5.3.00.0131.41212.94

preferences:
47.24 ms | 401 KiB | 5 Q