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.2d\n", (microtime(true) - $time) * 1000) . 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.2d\n", (microtime(true) - $time) * 1000); // 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.2d\n", (microtime(true) - $time) * 1000);

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.0040.02219.32
7.4.00.0130.01719.89
7.3.130.0070.02119.98
7.3.120.0120.01819.68
7.3.110.0160.01519.82
7.3.100.0050.01219.79
7.3.90.0090.01219.72
7.3.80.0120.00519.65
7.3.70.0030.01619.64
7.3.60.0110.01019.66
7.3.50.0110.00619.69
7.3.40.0070.01019.61
7.3.30.0030.01719.63
7.3.20.0090.00922.61
7.3.10.0120.01022.34
7.3.00.0100.01022.43
7.2.260.0150.01519.81
7.2.250.0090.02119.78
7.2.240.0090.02019.75
7.2.230.0090.01219.66
7.2.220.0080.01819.97
7.2.210.0070.01719.82
7.2.200.0060.01419.69
7.2.190.0080.01519.82
7.2.180.0110.00919.80
7.2.170.0090.01119.87
7.2.160.0000.02019.89
7.2.150.0070.01423.02
7.2.140.0120.00922.57
7.2.130.0070.01722.51
7.2.120.0100.01522.56
7.2.110.0050.01522.40
7.2.100.0040.01622.41
7.2.90.0090.01522.68
7.2.80.0060.02022.68
7.2.70.0120.01222.68
7.2.60.0110.01322.63
7.2.50.0080.01322.79
7.2.40.0100.01522.75
7.2.30.0050.01622.70
7.2.20.0120.01122.68
7.2.10.0090.01122.69
7.2.00.0080.01523.45
7.1.330.0060.01821.72
7.1.320.0020.02221.75
7.1.310.0050.01621.71
7.1.300.0070.01421.61
7.1.290.0050.01821.65
7.1.280.0090.01721.50
7.1.270.0060.01821.71
7.1.260.0040.02021.79
7.1.250.0050.02021.59
7.1.240.0090.01221.71
7.1.230.0050.01521.73
7.1.220.0060.01521.77
7.1.210.0110.00821.62
7.1.200.0070.01321.67
7.1.190.0080.01121.47
7.1.180.0050.01521.75
7.1.170.0060.01421.86
7.1.160.0050.01421.77
7.1.150.0080.01021.73
7.1.140.0020.01621.63
7.1.130.0050.01321.76
7.1.120.0020.01821.68
7.1.110.0050.01721.62
7.1.100.0390.01620.50
7.1.90.0070.01221.85
7.1.80.0080.01421.65
7.1.70.0040.01822.06
7.1.60.0020.01922.13
7.1.50.0050.01522.13
7.1.40.0080.01021.69
7.1.30.0050.01421.81
7.1.20.0050.01321.62
7.1.10.0060.01121.57
7.1.00.0070.03923.87
7.0.330.0070.01721.39
7.0.320.0020.01921.40
7.0.310.0090.01021.43
7.0.300.0020.01621.42
7.0.290.0060.01421.50
7.0.280.0070.01321.36
7.0.270.0080.01221.47
7.0.260.0030.01621.42
7.0.250.0070.01421.36
7.0.240.0030.01321.43
7.0.230.0110.01021.46
7.0.220.0040.01721.33
7.0.210.0050.01521.38
7.0.200.0050.01621.83
7.0.190.0000.01821.44
7.0.180.0030.01621.54
7.0.170.0050.01521.42
7.0.160.0090.01321.31
7.0.150.0060.01621.44
7.0.140.0030.03923.51
7.0.130.0020.01721.45
7.0.120.0080.01321.38
7.0.110.0030.01621.33
7.0.100.0040.01621.32
7.0.90.0030.01421.38
7.0.80.0050.01421.38
7.0.70.0050.01521.34
7.0.60.0060.03322.52
7.0.50.0050.03521.69
7.0.40.0080.03720.83
7.0.30.0220.03920.90
7.0.20.0160.02920.81
7.0.10.0090.03320.86
7.0.00.0060.03920.93
5.6.400.0100.04028.38
5.6.390.0110.03928.66
5.6.380.0070.03828.51
5.6.370.0090.03628.41
5.6.360.0100.03528.49
5.6.350.0170.02828.21
5.6.340.0150.02928.62
5.6.330.0080.03628.36
5.6.320.0120.03328.71
5.6.310.0140.03428.55
5.6.300.0140.03128.19
5.6.290.0090.03328.60
5.6.280.0110.05730.57
5.6.270.0180.02928.61
5.6.260.0140.03228.51
5.6.250.0100.03028.47
5.6.240.0130.02928.23
5.6.230.0170.02728.62
5.6.220.0110.03228.67
5.6.210.0140.05230.47
5.6.200.0100.05529.56
5.6.190.0150.04830.51
5.6.180.0180.05530.39
5.6.170.0190.03630.48
5.6.160.0140.05930.42
5.6.150.0110.04529.57
5.6.140.0090.04129.60
5.6.130.0100.05629.62
5.6.120.0170.05530.56
5.6.110.0120.04030.56
5.6.100.0090.04330.55
5.6.90.0150.05430.56
5.6.80.0070.04530.46
5.6.70.0130.03128.46
5.6.60.0080.03928.30
5.6.50.0170.02928.22
5.6.40.0100.03728.36
5.6.30.0120.03328.52
5.6.20.0200.02828.43
5.6.10.0130.03028.24
5.6.00.0130.03228.38
5.5.380.0130.03126.74
5.5.370.0030.04026.89
5.5.360.0110.03426.89
5.5.350.0130.04029.30
5.5.340.0160.03528.54
5.5.330.0100.04629.32
5.5.320.0230.05229.25
5.5.310.0170.05429.30
5.5.300.0090.05828.44
5.5.290.0100.05828.59
5.5.280.0200.03329.55
5.5.270.0080.05629.53
5.5.260.0120.05029.52
5.5.250.0090.06029.46
5.5.240.0190.05729.30
5.5.230.0080.03626.61
5.5.220.0140.03226.71
5.5.210.0160.02926.85
5.5.200.0110.03326.81
5.5.190.0190.02326.65
5.5.180.0130.03726.89
5.5.170.0140.03428.35
5.5.160.0080.03626.74
5.5.150.0110.03326.82
5.5.140.0100.03426.95
5.5.130.0160.03126.56
5.5.120.0120.03226.76
5.5.110.0020.03926.72
5.5.100.0070.03926.73
5.5.90.0090.03226.81
5.5.80.0170.03126.85
5.5.70.0130.03226.68
5.5.60.0120.03526.53
5.5.50.0100.03526.66
5.5.40.0100.03426.68
5.5.30.0070.03726.57
5.5.20.0150.03026.87
5.5.10.0130.02926.56
5.5.00.0120.03526.77
5.4.450.0170.04527.75
5.4.440.0210.04527.90
5.4.430.0160.04527.81
5.4.420.0120.04827.76
5.4.410.0170.04527.77
5.4.400.0150.05527.45
5.4.390.0120.04927.58
5.4.380.0140.06027.58
5.4.370.0200.05527.49
5.4.360.0140.04827.54
5.4.350.0070.04225.86
5.4.340.0100.04125.92
5.4.330.0120.03125.05
5.4.320.0120.04025.99
5.4.310.0110.03826.13
5.4.300.0110.04126.10
5.4.290.0110.04426.06
5.4.280.0100.04525.97
5.4.270.0130.03726.00
5.4.260.0110.04226.09
5.4.250.0140.03826.18
5.4.240.0130.03826.09
5.4.230.0140.03926.06
5.4.220.0150.04025.92
5.4.210.0150.03925.87
5.4.200.0100.04725.96
5.4.190.0080.04825.95
5.4.180.0130.04125.99
5.4.170.0140.04026.04
5.4.160.0120.03825.97
5.4.150.0100.04126.01
5.4.140.0150.04026.15
5.4.130.0210.03525.99
5.4.120.0180.04125.91
5.4.110.0150.03925.83
5.4.100.0180.04225.93
5.4.90.0210.03625.98
5.4.80.0140.04225.78
5.4.70.0140.04025.93
5.4.60.0110.04625.95
5.4.50.0190.03626.01
5.4.40.0160.03625.78
5.4.30.0140.04425.87
5.4.20.0120.03825.90
5.4.10.0100.04325.90
5.4.00.0160.03225.75
5.3.290.0180.78945.80
5.3.280.0250.78145.68
5.3.270.0210.81145.69
5.3.260.0250.79745.65
5.3.250.0220.87745.55
5.3.240.0220.80945.54
5.3.230.0200.81945.69
5.3.220.0280.81945.54
5.3.210.0250.85745.47
5.3.200.0270.82645.57
5.3.190.0220.84445.58
5.3.180.0230.82245.64
5.3.170.0330.79745.54
5.3.160.0350.81645.63
5.3.150.0220.86245.67
5.3.140.0200.86845.65
5.3.130.0210.82145.62
5.3.120.0320.81845.56
5.3.110.0250.83445.47
5.3.100.0390.82845.46
5.3.90.0170.85545.35
5.3.80.0250.89245.23
5.3.70.0190.82245.30
5.3.60.0280.83145.13
5.3.50.0320.82545.17
5.3.40.0160.81845.20
5.3.30.0310.78945.19
5.3.20.0250.85244.97
5.3.10.0150.82945.03
5.3.00.0230.82844.91
5.2.170.0200.82042.63
5.2.160.0250.86642.64
5.2.150.0200.87242.59
5.2.140.0280.84642.56
5.2.130.0180.79742.55
5.2.120.0300.81942.39
5.2.110.0280.81342.49
5.2.100.0270.81542.44
5.2.90.0180.80942.33
5.2.80.0220.86342.35
5.2.70.0280.79942.35
5.2.60.0130.83542.44
5.2.50.0311.12141.96
5.2.40.0231.08241.85
5.2.30.0161.04041.92
5.2.20.0151.04541.97
5.2.10.0080.60441.91
5.2.00.0182.10141.88
5.1.60.0281.10049.96
5.1.50.0281.09850.15
5.1.40.0251.15850.17
5.1.30.0221.10550.44
5.1.20.0151.21550.33
5.1.10.0231.23750.16
5.1.00.0271.19150.15
5.0.50.0221.20648.84
5.0.40.0231.18048.69
5.0.30.0231.19048.65
5.0.20.0201.21248.75
5.0.10.0221.19548.62
5.0.00.0171.17048.56
4.4.90.0131.22346.45
4.4.80.0221.16346.84
4.4.70.0231.28346.58
4.4.60.0171.16646.49
4.4.50.0301.27146.54
4.4.40.0151.15046.56
4.4.30.0231.17946.59
4.4.20.0151.16846.58
4.4.10.0221.23346.53
4.4.00.0221.24846.47
4.3.110.0181.17946.42
4.3.100.0221.16846.43
4.3.90.0171.21546.43
4.3.80.0271.15746.44
4.3.70.0181.25146.34
4.3.60.0171.24746.45
4.3.50.0201.13246.35
4.3.40.0131.16646.38
4.3.30.0221.15445.45
4.3.20.0181.22045.37
4.3.10.0151.26645.51
4.3.00.0171.16845.52

preferences:
39.24 ms | 401 KiB | 5 Q