3v4l.org

run code in 300+ PHP versions simultaneously
<?php $context = array('test' => array()); // optionally fill-in the test value with lots of data for ($i = 0; $i < 100000; $i++) { $context['test'][$i] = $i; } // you can also just create a big string // $context = str_repeat(' ', 1000000); // benchmark $time = microtime(true); for ($i = 0; $i < 100; $i++) { // the snippet of code to benchmark $tmp = isset($context['test']) ? $context['test'] : ''; } printf("TERNARY: %0.5d\n", (microtime(true) - $time)) . PHP_EOL; // benchmark $time = microtime(true); for ($i = 0; $i < 100; $i++) { // the snippet of code to benchmark $tmp = ''; if (isset($context['test'])) { $tmp = $context['test']; } } printf("IF : %0.5d\n", (microtime(true) - $time)); // benchmark $time = microtime(true); for ($i = 0; $i < 100; $i++) { // the snippet of code to benchmark if (isset($context['test'])) { $tmp = $context['test']; } else { $tmp = ''; } } printf("IF/ELSE: %0.5d\n", (microtime(true) - $time));

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.2.00.0070.01324.88
7.1.100.1280.01021.56
7.1.70.0070.01823.18
7.1.60.0100.02423.30
7.1.50.0330.01540.93
7.1.00.0100.07728.22
7.0.200.0040.00722.78
7.0.140.0070.04728.21
7.0.60.0170.08324.92
7.0.50.0030.07022.63
7.0.40.0070.08323.61
7.0.30.0370.08323.62
7.0.20.0270.04023.62
7.0.10.0030.04723.77
7.0.00.0170.04323.59
5.6.280.0030.10335.16
5.6.210.0270.08734.70
5.6.200.0200.08332.11
5.6.190.0130.08734.36
5.6.180.0270.10734.51
5.6.170.0430.09334.32
5.6.160.0170.10734.30
5.6.150.0200.09732.15
5.6.140.0130.08732.16
5.6.130.0100.10032.10
5.6.120.0170.10334.91
5.6.110.0130.08035.02
5.6.100.0130.10034.93
5.6.90.0100.09735.13
5.6.80.0400.07734.54
5.5.350.0200.10034.39
5.5.340.0030.08731.89
5.5.330.0170.05034.20
5.5.320.0230.06334.22
5.5.310.0370.08734.10
5.5.300.0200.06732.02
5.5.290.0170.10031.97
5.5.280.0170.10334.81
5.5.270.0170.04334.66
5.5.260.0170.10734.88
5.5.250.0030.06034.62
5.5.240.0000.08334.29
5.4.450.0370.06333.36
5.4.440.0270.06033.48
5.4.430.0570.05033.50
5.4.420.0130.08333.27
5.4.410.0200.11032.87
5.4.400.0200.09032.52
5.4.390.0270.11032.72
5.4.380.0200.10732.56
5.4.370.0270.07732.68
5.4.360.0430.09332.69
5.4.350.0070.05727.90
5.4.340.0170.04727.67
5.4.320.0100.05328.29
5.4.310.0100.06328.25
5.4.300.0100.05728.23
5.4.290.0130.05328.16
5.4.280.0100.06028.11
5.4.270.0130.06328.13
5.4.260.0130.08028.05
5.4.250.0100.05728.09
5.4.240.0200.05328.21
5.4.230.0130.05328.03
5.4.220.0030.06028.09
5.4.210.0200.04328.05
5.4.200.0100.06028.04
5.4.190.0100.05328.05
5.4.180.0070.05728.12
5.4.170.0130.05028.07
5.4.160.0100.05328.19
5.4.150.0130.05328.12
5.4.140.0270.05027.75
5.4.130.0130.05327.68
5.4.120.0200.04727.73
5.4.110.0030.07027.69
5.4.100.0100.05727.75
5.4.90.0100.05727.74
5.4.80.0100.05327.69
5.4.70.0130.05027.91
5.4.60.0170.07727.67
5.4.50.0200.05727.86
5.4.40.0130.05727.66
5.4.30.0230.06027.89
5.4.20.0170.05727.71
5.4.10.0130.05727.82
5.4.00.0200.05027.13
5.3.290.0330.90747.71
5.3.280.0330.86347.76
5.3.270.0470.88747.68
5.3.260.0230.85347.57
5.3.250.0201.05347.69
5.3.240.0301.12747.69
5.3.230.0431.21047.70
5.3.220.0071.10747.62
5.3.210.0301.25747.65
5.3.200.0431.13347.55
5.3.190.0300.89747.60
5.3.180.0400.99047.56
5.3.170.0331.00347.71
5.3.160.0271.08747.62
5.3.150.0331.01747.57
5.3.140.0270.98047.69
5.3.130.0271.15747.76
5.3.120.0271.09747.70
5.3.110.0331.19747.63
5.3.100.0270.91747.09
5.3.90.0330.87747.05
5.3.80.0300.93347.12
5.3.70.0200.88346.96
5.3.60.0170.93046.99
5.3.50.0100.92046.95
5.3.40.0470.97346.97
5.3.30.0400.87746.92
5.3.20.0200.90046.77
5.3.10.0300.91346.64
5.3.00.0270.94046.70
5.2.170.0370.93743.43
5.2.160.0330.90343.44
5.2.150.0230.84743.41
5.2.140.0300.90343.46
5.2.130.0230.83743.38
5.2.120.0070.89043.31
5.2.110.0230.84043.32
5.2.100.0230.93743.31
5.2.90.0331.09043.34
5.2.80.0370.90043.49
5.2.70.0400.85343.31
5.2.60.0200.82043.33
5.2.50.0131.17742.74
5.2.40.0131.17042.59
5.2.30.0101.18342.61
5.2.20.0201.20042.66
5.2.10.0130.62742.86
5.2.00.0102.47742.54
5.1.60.0301.25350.90
5.1.50.0271.26350.89
5.1.40.0271.29350.84
5.1.30.0201.16051.21
5.1.20.0571.16751.19
5.1.10.0201.36750.95
5.1.00.0501.24350.94
5.0.50.0131.15349.43
5.0.40.0171.18349.29
5.0.30.0271.26749.10
5.0.20.0171.18049.07
5.0.10.0371.23749.14
5.0.00.0231.37749.05
4.4.90.0201.24746.90
4.4.80.0171.13046.85
4.4.70.0101.31046.87
4.4.60.0201.17346.91
4.4.50.0271.17346.93
4.4.40.0301.17046.87
4.4.30.0171.16746.88
4.4.20.0231.17046.93
4.4.10.0201.19746.94
4.4.00.0131.14746.89
4.3.110.0231.18046.78
4.3.100.0171.14746.79
4.3.90.0071.26046.84
4.3.80.0231.12046.76
4.3.70.0131.25746.79
4.3.60.0231.19346.93
4.3.50.0231.12046.75
4.3.40.0271.05046.73
4.3.30.0371.08045.65
4.3.20.0171.11345.50
4.3.10.0101.20745.61
4.3.00.0271.42345.46

preferences:
34.77 ms | 400 KiB | 5 Q