3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); ini_set('display_errors', '1'); function get_user_meta($user_id, $key, $ingle) { return 5; } function get_curriculum($id) { return [ 1, 2, 3 ]; } class init { private $time_spent; public function __construct() { $this->time_spent = array(); } public function get_course_unit_time_spent($user_id, $course_id, $unit_id) { if (empty($this->time_spent[$course_id]) || empty($this->time_spent[$course_id][$unit_id])) { $this->time_spent[$course_id][$unit_id] = get_user_meta($user_id, 'time_spent_'.$course_id.'_'.$unit_id, true); if (empty($this->time_spent[$course_id][$unit_id])) { $this->time_spent[$course_id][$unit_id] = 0; } } return $this->time_spent[$course_id][$unit_id]; } public function get_course_time_spent($user_id, $course_id) { if (empty($this->time_spent[$course_id])) { $time_spent = 0; foreach ((array) get_curriculum($course_id) as $unit_id) { if(is_numeric($unit_id)){ $time_spent += $this->get_course_unit_time_spent($user_id, $course_id, $unit_id); } } $this->time_spent[$course_id] = $time_spent; } return $this->time_spent[$course_id]; } } $init = new init; echo $init->get_course_time_spent(1, 234).PHP_EOL; echo $init->get_course_time_spent(2, 2345).PHP_EOL; echo $init->get_course_time_spent(3, 23456).PHP_EOL; print_r($init);

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.5.00.0140.00919.96
8.4.150.0020.00014.05
8.4.140.0150.00617.75
8.4.130.0090.01117.91
8.4.120.0080.00120.31
8.4.110.0070.00718.90
8.4.100.0130.00817.70
8.4.90.0060.00320.34
8.4.80.0040.00419.11
8.4.70.0060.00317.98
8.4.60.0120.00918.95
8.4.50.0110.00920.57
8.4.40.0100.00017.72
8.4.30.0060.00317.73
8.4.20.0160.00319.58
8.4.10.0000.00919.73
8.3.280.0150.00620.18
8.3.270.0080.01116.64
8.3.260.0080.00616.56
8.3.250.0070.00217.30
8.3.240.0120.00616.65
8.3.230.0110.00916.56
8.3.220.0060.00318.84
8.3.210.0120.00516.80
8.3.200.0050.00416.64
8.3.190.0090.00617.34
8.3.180.0040.00418.92
8.3.170.0090.00920.71
8.3.160.0040.01517.36
8.3.150.0150.00420.69
8.3.140.0110.00718.27
8.3.130.0060.00318.38
8.3.120.0060.00320.68
8.3.110.0060.00320.94
8.3.100.0040.00416.83
8.3.90.0090.00926.77
8.3.80.0090.00019.36
8.3.70.0120.00918.27
8.3.60.0150.00318.55
8.3.50.0120.00118.11
8.3.40.0080.00818.90
8.3.30.0150.00018.79
8.3.20.0040.00420.34
8.3.10.0030.00621.85
8.3.00.0090.00019.13
8.2.290.0100.01018.96
8.2.280.0050.00318.42
8.2.270.0070.00017.17
8.2.260.0050.00519.04
8.2.250.0090.00018.62
8.2.240.0080.00317.32
8.2.230.0000.00822.58
8.2.220.0000.00924.06
8.2.210.0070.00726.77
8.2.200.0030.00618.88
8.2.190.0000.01516.58
8.2.180.0110.00418.17
8.2.170.0060.00922.96
8.2.160.0070.00720.35
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0080.00026.16
8.2.120.0030.00619.36
8.2.110.0080.00421.12
8.2.100.0000.01217.91
8.2.90.0080.00017.84
8.2.80.0080.00019.28
8.2.70.0050.00317.93
8.2.60.0050.00318.05
8.2.50.0060.00318.16
8.2.40.0000.00720.55
8.2.30.0040.00419.50
8.2.20.0040.00418.22
8.2.10.0040.00418.07
8.2.00.0040.00418.40
8.1.330.0070.01116.19
8.1.320.0110.01116.32
8.1.310.0040.01116.60
8.1.300.0120.00618.23
8.1.290.0040.00430.84
8.1.280.0110.00425.92
8.1.270.0000.00819.95
8.1.260.0090.00328.09
8.1.250.0070.00028.09
8.1.240.0060.00322.18
8.1.230.0060.00620.97
8.1.220.0040.00417.74
8.1.210.0100.00018.77
8.1.200.0050.00317.35
8.1.190.0000.00817.35
8.1.180.0040.00418.10
8.1.170.0080.00018.66
8.1.160.0040.00418.81
8.1.150.0040.00420.27
8.1.140.0000.00818.99
8.1.130.0050.00519.02
8.1.120.0040.00417.49
8.1.110.0050.00317.35
8.1.100.0000.00717.53
8.1.90.0000.00817.38
8.1.80.0040.00417.40
8.1.70.0000.00717.39
8.1.60.0030.00617.64
8.1.50.0040.00417.57
8.1.40.0050.00317.59
8.1.30.0030.00617.58
8.1.20.0070.00017.69
8.1.10.0000.00817.52
8.1.00.0080.00017.44
8.0.300.0000.00720.03
8.0.290.0000.00716.88
8.0.280.0030.00318.48
8.0.270.0000.00718.11
8.0.260.0030.00317.26
8.0.250.0030.00317.00
8.0.240.0080.00016.93
8.0.230.0070.00016.98
8.0.220.0000.00716.94
8.0.210.0030.00316.93
8.0.200.0000.00716.97
8.0.190.0080.00016.99
8.0.180.0000.00816.98
8.0.170.0100.00016.96
8.0.160.0040.00416.87
8.0.150.0050.00516.77
8.0.140.0000.00816.89
8.0.130.0050.00013.36
8.0.120.0050.00216.80
8.0.110.0000.00716.81
8.0.100.0040.00416.96
8.0.90.0000.00816.89
8.0.80.0070.01016.95
8.0.70.0080.00016.96
8.0.60.0050.00316.86
8.0.50.0040.00416.88
8.0.30.0110.00817.12
8.0.20.0110.00917.40
8.0.10.0030.00517.03
8.0.00.0090.01116.71
7.4.330.0050.00015.55
7.4.320.0000.00616.56
7.4.300.0000.00716.54
7.4.290.0000.00716.63
7.4.280.0000.00816.53
7.4.270.0000.00716.55
7.4.260.0030.00316.52
7.4.250.0000.00816.53
7.4.240.0060.00316.65
7.4.230.0000.00716.38
7.4.220.0040.00416.43
7.4.210.0110.01116.60
7.4.200.0050.00316.67
7.4.160.0110.00616.43
7.4.150.0150.00617.40
7.4.140.0110.00917.86
7.4.130.0090.00816.35
7.4.120.0070.01216.54
7.4.110.0040.01316.35
7.4.100.0040.01316.49
7.4.90.0130.00316.53
7.4.80.0090.00919.39
7.4.70.0050.01416.57
7.4.60.0120.00916.49
7.4.50.0030.01316.61
7.4.40.0130.00416.45
7.4.00.0040.00814.91
7.3.330.0020.00213.40
7.3.320.0060.00013.35
7.3.310.0000.00716.41
7.3.300.0000.00916.34
7.3.290.0070.01016.35
7.3.280.0070.00716.38
7.3.270.0110.00717.40
7.3.260.0100.00716.53
7.3.250.0130.00416.57
7.3.240.0120.00716.38
7.3.230.0030.01416.55
7.3.210.0050.01316.40
7.3.200.0090.00816.33
7.3.190.0100.00616.36
7.3.180.0130.00316.65
7.3.170.0110.00416.52
7.3.160.0160.00716.54
7.2.330.0110.00816.91
7.2.320.0140.00316.84
7.2.310.0120.00916.58
7.2.300.0000.01716.77
7.2.290.0070.01416.65
7.2.60.0030.01216.91
7.2.10.0250.00717.97
7.2.00.0280.00818.05
7.1.200.0060.00915.85
7.1.130.0210.01416.97
7.1.120.0240.00916.84
7.1.110.0270.01016.03
7.1.100.0300.00916.29
7.1.90.0290.00715.98
7.1.80.0510.00315.93
7.1.70.0200.01315.14
7.1.60.0360.01333.22
7.1.50.0370.01332.93
7.1.40.0440.00732.57
7.1.30.0890.01232.67
7.1.20.0450.00732.63
7.1.10.0250.01214.81
7.1.00.0250.01114.93

preferences:
15.81 ms | 403 KiB | 5 Q