3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('display_errors', 1); error_reporting(E_ALL); // Make a big, honkin test array // You may need to adjust this depth to avoid memory limit errors $testArray = fillArray(0, 5); // Time json encoding $start = microtime(true); json_encode($testArray); $jsonTime = microtime(true) - $start; echo "JSON encoded in $jsonTime seconds\n"; // Time serialization $start = microtime(true); serialize($testArray); $serializeTime = microtime(true) - $start; echo "PHP serialized in $serializeTime seconds\n"; // Compare them if ($jsonTime < $serializeTime) { printf("json_encode() was roughly %01.2f%% faster than serialize()\n", ($serializeTime / $jsonTime - 1) * 100); } elseif ($serializeTime < $jsonTime ) { printf("serialize() was roughly %01.2f%% faster than json_encode()\n", ($jsonTime / $serializeTime - 1) * 100); } else { echo "Unpossible!\n"; } function fillArray( $depth, $max ) { static $seed; if (is_null($seed)) { $seed = array('a', 2, 'c', 4, 'e', 6, 'g', 8, 'i', 10); } if ($depth < $max) { $node = array(); foreach ($seed as $key) { $node[$key] = fillArray($depth + 1, $max); } return $node; } return 'empty'; }

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)
8.1.220.0080.01926.97
8.1.130.0160.01626.98
8.1.120.0120.02327.79
8.1.110.0150.02027.79
8.1.100.0180.01827.74
8.1.90.0170.01427.81
8.1.80.0180.01427.79
8.1.70.0110.01827.39
8.1.60.0170.01827.73
8.1.50.0200.01727.68
8.1.40.0150.02227.75
8.1.30.0150.02227.72
8.1.20.0130.02427.67
8.1.10.0160.01827.68
8.1.00.0140.02327.62
8.0.260.0070.02125.99
8.0.250.0180.01326.92
8.0.240.0160.01526.95
8.0.230.0120.01826.87
8.0.220.0100.02026.89
8.0.210.0130.01926.87
8.0.200.0140.01826.75
8.0.190.0140.01726.70
8.0.180.0110.02026.75
8.0.170.0120.02126.71
8.0.160.0120.01826.71
8.0.150.0150.01626.61
8.0.140.0180.01426.68
8.0.130.0100.02126.33
8.0.120.0110.02326.44
8.0.110.0160.01726.45
8.0.100.0120.02126.45
8.0.90.0150.01926.49
8.0.80.0140.02126.45
8.0.70.0150.02026.46
8.0.60.0140.02026.44
8.0.50.0080.02326.40
8.0.30.0130.01826.41
8.0.20.0160.02326.50
8.0.10.0150.02826.50
8.0.00.0170.02726.58
7.4.330.0070.02222.28
7.4.320.0180.01626.48
7.4.300.0120.02026.28
7.4.290.0140.02026.25
7.4.280.0170.01926.29
7.4.270.0180.01726.29
7.4.260.0110.02126.15
7.4.250.0170.02026.20
7.4.240.0140.02026.12
7.4.230.0130.02026.04
7.4.220.0100.02226.00
7.4.210.0150.01726.05
7.4.200.0110.02125.99
7.4.190.0120.02126.19
7.4.180.0120.02126.20
7.4.160.0170.03325.93
7.4.150.0120.02726.04
7.4.140.0180.02425.97
7.4.130.0170.02326.02
7.4.120.0150.02426.09
7.4.110.0160.02926.02
7.4.100.0170.02726.06
7.4.90.0200.02326.01
7.4.80.0120.02925.96
7.4.70.0170.02625.93
7.4.60.0150.02625.96
7.4.50.0160.02825.88
7.4.40.0160.02725.90
7.4.30.0190.02725.89
7.4.20.0150.03125.88
7.4.10.0170.02925.84
7.4.00.0150.02625.66
7.3.330.0160.01926.04
7.3.320.0130.02326.12
7.3.310.0120.02226.04
7.3.300.0110.02226.00
7.3.290.0130.02025.90
7.3.280.0140.02026.07
7.3.270.0180.02225.90
7.3.260.0160.02425.90
7.3.250.0180.02225.93
7.3.240.0160.02526.00
7.3.230.0140.03425.89
7.3.220.0170.02925.84
7.3.210.0140.02925.87
7.3.200.0190.02425.92
7.3.190.0160.02825.86
7.3.180.0190.02525.90
7.3.170.0190.02525.79
7.3.160.0190.02525.82
7.3.150.0160.03225.81
7.3.140.0180.02825.88
7.3.130.0180.02525.75
7.3.120.0180.03025.41
7.3.110.0180.02825.30
7.3.100.0180.03725.35
7.3.90.0190.03025.43
7.3.80.0170.02825.31
7.3.70.0200.03225.29
7.3.60.0190.03325.31
7.3.50.0200.03125.36
7.3.40.0160.03025.31
7.3.30.0180.03025.32
7.3.20.0220.03425.49
7.3.10.0240.03125.44
7.3.00.0250.03025.42
7.2.340.0170.03425.98
7.2.330.0190.02825.94
7.2.320.0170.03125.96
7.2.310.0200.02925.94
7.2.300.0180.02825.94
7.2.290.0170.03025.91
7.2.280.0190.02725.96
7.2.270.0180.03025.96
7.2.260.0140.03325.97
7.2.250.0200.03125.78
7.2.240.0190.03325.58
7.2.230.0240.03925.57
7.2.220.0190.03325.50
7.2.210.0220.03425.45
7.2.200.0180.03825.60
7.2.190.0210.03425.51
7.2.180.0210.03125.56
7.2.170.0190.03625.56
7.2.160.0200.03025.57
7.2.150.0230.03725.74
7.2.140.0210.04125.72
7.2.130.0260.03425.75
7.2.120.0210.03525.76
7.2.110.0310.03325.75
7.2.100.0270.02725.75
7.2.90.0910.03125.60
7.2.80.1090.03325.66
7.2.70.1100.03225.67
7.2.60.1880.03425.58
7.2.50.1630.03225.61
7.2.40.1680.03425.69
7.2.30.1790.03325.66
7.2.20.1490.03325.63
7.2.10.1170.03225.62
7.2.00.1360.03425.75
7.1.330.0300.03924.86
7.1.320.0240.03524.73
7.1.310.0240.03624.75
7.1.300.0210.03624.72
7.1.290.0300.03724.70
7.1.280.0300.03624.73
7.1.270.0200.03524.69
7.1.260.0220.03724.68
7.1.250.0240.03724.65
7.1.240.0260.03724.62
7.1.230.0220.04124.69
7.1.220.0240.03424.67
7.1.210.1580.03324.58
7.1.200.1000.03924.56
7.1.190.1230.03624.57
7.1.180.0890.03624.60
7.1.170.1940.03624.47
7.1.160.1820.03424.69
7.1.150.1760.03224.60
7.1.140.1290.03424.71
7.1.130.1380.03224.70
7.1.120.1340.03524.62
7.1.110.1190.03424.67
7.1.100.1360.03624.69
7.1.90.0370.03524.66
7.1.80.0260.03324.65
7.1.70.0500.03524.55
7.1.60.0870.03526.63
7.1.50.0850.03626.64
7.1.40.0820.03526.57
7.1.30.0490.03726.56
7.1.20.0740.03726.54
7.1.10.0620.03324.54
7.1.00.0830.03324.49
7.0.330.0240.03924.70
7.0.320.0250.03824.65
7.0.310.0930.03624.57
7.0.300.1840.03624.50
7.0.290.1670.03924.65
7.0.280.0880.04124.61
7.0.270.1210.03824.71
7.0.260.1200.03724.71
7.0.250.1290.03624.75
7.0.240.1400.03824.71
7.0.230.0550.03624.74
7.0.220.0280.03824.74
7.0.210.0700.03524.68
7.0.200.0980.03724.67
7.0.190.0470.03924.64
7.0.180.0660.04224.60
7.0.170.0500.03824.61
7.0.160.0550.03724.58
7.0.150.0610.03824.63
7.0.140.0620.03624.61
7.0.130.0710.03824.66
7.0.120.0320.03524.62
7.0.110.0450.04124.62
7.0.100.0690.03724.59
7.0.90.0760.03724.56
7.0.80.0400.03724.57
7.0.70.0600.03624.56
7.0.60.0370.03824.60
7.0.50.0730.03724.60
7.0.40.0530.04224.08
7.0.30.0650.03824.12
7.0.20.0560.03924.10
7.0.10.0640.04024.12
7.0.00.0450.03824.05
5.6.400.0400.20747.35
5.6.390.0380.21247.37
5.6.380.0390.20347.41
5.6.370.0400.20847.34
5.6.360.0430.20547.38
5.6.350.0350.20247.34
5.6.340.0400.19647.39
5.6.330.0400.19447.34
5.6.320.0430.19947.34
5.6.310.0410.20147.35
5.6.300.0360.19647.77
5.6.290.0360.20247.81
5.6.280.0400.19847.87
5.6.270.0390.19947.82
5.6.260.0390.20747.92
5.6.250.0370.20447.81
5.6.240.0430.21247.86
5.6.230.0420.20647.89
5.6.220.0320.20847.88
5.6.210.0420.21247.91
5.6.200.0460.20647.89
5.6.190.0410.19947.92
5.6.180.0410.20947.93
5.6.170.0380.20947.99
5.6.160.0400.20947.87
5.6.150.0390.21147.89
5.6.140.0420.20747.88
5.6.130.0440.20847.93
5.6.120.0380.20547.95
5.6.110.0390.19547.83
5.6.100.0380.21947.89
5.6.90.0370.21647.82
5.6.80.0390.20547.75
5.6.70.0400.21247.77
5.6.60.0320.20947.73
5.6.50.0410.22047.74
5.6.40.0400.20747.79
5.6.30.0400.20847.72
5.6.20.0410.20847.77
5.6.10.0360.20147.74
5.6.00.0390.21047.78
5.5.380.0360.20547.41
5.5.370.0370.21047.39
5.5.360.0400.19847.25
5.5.350.0440.22047.27
5.5.340.0430.22047.42
5.5.330.0410.20747.33
5.5.320.0390.20647.32
5.5.310.0360.20747.31
5.5.300.0370.21747.25
5.5.290.0380.20947.30
5.5.280.0390.21147.37
5.5.270.0380.21047.34
5.5.260.0390.21047.30
5.5.250.0400.21547.33
5.5.240.0390.20347.30
5.5.230.0400.20147.20
5.5.220.0400.20847.23
5.5.210.0390.20647.23
5.5.200.0400.21647.17
5.5.190.0400.21347.17
5.5.180.0410.21347.12
5.5.170.0420.20847.18
5.5.160.0410.21147.22
5.5.150.0410.20847.20
5.5.140.0400.21347.11
5.5.130.0410.21647.15
5.5.120.0390.21047.18
5.5.110.0400.20447.14
5.5.100.0390.22347.21
5.5.90.0400.21147.20
5.5.80.0380.21147.24
5.5.70.0400.22547.21
5.5.60.0390.20547.21
5.5.50.0410.20147.25
5.5.40.0410.22247.24
5.5.30.0400.21247.21
5.5.20.0390.21747.23
5.5.10.0390.21647.17
5.5.00.0380.21047.17
5.4.450.0390.20344.74
5.4.440.0350.20844.67
5.4.430.0340.20844.69
5.4.420.0360.20944.71
5.4.410.0390.21944.68
5.4.400.0330.21544.59
5.4.390.0400.21044.58
5.4.380.0350.20744.60
5.4.370.0370.21244.61
5.4.360.0400.21344.61
5.4.350.0370.21744.56
5.4.340.0400.21744.59
5.4.330.0350.21543.79
5.4.320.0360.21944.65
5.4.310.0400.21344.58
5.4.300.0410.21544.62
5.4.290.0400.22344.59
5.4.280.0370.21144.62
5.4.270.0400.20544.62
5.4.260.0360.20044.56
5.4.250.0390.21544.54
5.4.240.0410.21144.54
5.4.230.0390.21644.48
5.4.220.0380.22944.51
5.4.210.0440.22144.56
5.4.200.0360.22144.50
5.4.190.0360.21044.47
5.4.180.0360.21844.50
5.4.170.0360.21544.58
5.4.160.0370.21944.48
5.4.150.0410.21544.53
5.4.140.0390.21644.33
5.4.130.0370.22344.37
5.4.120.0370.20844.40
5.4.110.0320.21244.39
5.4.100.0360.20944.39
5.4.90.0400.20244.40
5.4.80.0390.20444.43
5.4.70.0360.21244.38
5.4.60.0360.21644.34
5.4.50.0330.20744.34
5.4.40.0370.20044.38
5.4.30.0340.22144.37
5.4.20.0380.22144.36
5.4.10.0410.22044.40
5.4.00.0330.21944.22

preferences:
34.28 ms | 401 KiB | 5 Q