3v4l.org

run code in 300+ PHP versions simultaneously
<?php class factorial_of_a_number{ protected $n; public function __construct($n){ if(!is_int($n)){ throw new InvalidArgumentException('Not A Number or missing argument'); } $this->n = $n; } public function result(){ $factorial = 1; for($i=1; $i<= $this ->n;$i++){ $factorial *= $i; } return $factorial; } } $newfactorial = new factorial_of_a_number(2); echo $newfactorial->result();

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.3.60.0130.00718.43
8.3.50.0110.00722.89
8.3.40.0040.01118.58
8.3.30.0070.00719.13
8.3.20.0070.00020.34
8.3.10.0040.00423.48
8.3.00.0040.00419.38
8.2.180.0030.01316.38
8.2.170.0070.00722.96
8.2.160.0100.00720.43
8.2.150.0000.00824.18
8.2.140.0040.01124.66
8.2.130.0140.00026.16
8.2.120.0080.00021.04
8.2.110.0070.00322.04
8.2.100.0040.00819.66
8.2.90.0000.00719.21
8.2.80.0000.00817.97
8.2.70.0140.00017.36
8.2.60.0030.00718.05
8.2.50.0040.00418.07
8.2.40.0000.00818.34
8.2.30.0050.00218.13
8.2.20.0050.00217.68
8.2.10.0040.00418.14
8.2.00.0040.00417.86
8.1.280.0000.01425.92
8.1.270.0040.00424.02
8.1.260.0070.00026.35
8.1.250.0000.00828.09
8.1.240.0030.00623.73
8.1.230.0000.01119.01
8.1.220.0030.00617.79
8.1.210.0090.00018.77
8.1.200.0060.00317.34
8.1.190.0050.00317.23
8.1.180.0040.00418.10
8.1.170.0040.00418.68
8.1.160.0030.00622.07
8.1.150.0040.00418.84
8.1.140.0000.00717.38
8.1.130.0040.00417.70
8.1.120.0040.00417.52
8.1.110.0040.00417.52
8.1.100.0000.00717.41
8.1.90.0070.00017.36
8.1.80.0070.00017.50
8.1.70.0030.00317.40
8.1.60.0030.01017.48
8.1.50.0040.00417.42
8.1.40.0000.00817.42
8.1.30.0000.00817.68
8.1.20.0050.00217.58
8.1.10.0040.00417.59
8.1.00.0030.00617.55
8.0.300.0040.00418.77
8.0.290.0040.00416.75
8.0.280.0040.00218.51
8.0.270.0000.00817.17
8.0.260.0000.00617.13
8.0.250.0070.00016.98
8.0.240.0000.00716.87
8.0.230.0040.00416.93
8.0.220.0000.00716.88
8.0.210.0030.00316.93
8.0.200.0000.00716.94
8.0.190.0030.00516.98
8.0.180.0040.00416.96
8.0.170.0040.00416.95
8.0.160.0030.00316.90
8.0.150.0040.00416.88
8.0.140.0070.00416.86
8.0.130.0000.00613.29
8.0.120.0040.00416.85
8.0.110.0040.00416.86
8.0.100.0040.00416.98
8.0.90.0030.00316.79
8.0.80.0150.00016.86
8.0.70.0050.00316.96
8.0.60.0040.00416.79
8.0.50.0030.00516.86
8.0.30.0170.00416.95
8.0.20.0130.00617.40
8.0.10.0000.00816.97
8.0.00.0100.01016.84
7.4.330.0000.00615.12
7.4.320.0030.00316.43
7.4.300.0000.00616.59
7.4.290.0000.00716.59
7.4.280.0050.00316.50
7.4.270.0030.00316.42
7.4.260.0000.00716.48
7.4.250.0040.00416.53
7.4.240.0050.00316.60
7.4.230.0000.00716.35
7.4.220.0030.01516.70
7.4.210.0150.00016.54
7.4.200.0070.00016.63
7.4.160.0130.00316.38
7.4.150.0140.00417.40
7.4.140.0140.00517.86
7.4.130.0130.00516.49
7.4.120.0110.00516.53
7.4.110.0070.01016.69
7.4.100.0090.00916.64
7.4.90.0110.00716.56
7.4.80.0100.00719.39
7.4.70.0070.01016.56
7.4.60.0070.01016.69
7.4.50.0000.00416.56
7.4.40.0040.01716.65
7.4.30.0030.01316.55
7.4.00.0130.00315.20
7.3.330.0050.00013.31
7.3.320.0050.00013.35
7.3.310.0070.00016.19
7.3.300.0030.00316.33
7.3.290.0070.00716.39
7.3.280.0080.00816.42
7.3.270.0090.00917.40
7.3.260.0140.00916.70
7.3.250.0130.00616.35
7.3.240.0060.01516.47
7.3.230.0100.00716.61
7.3.210.0000.01716.55
7.3.200.0040.01819.39
7.3.190.0060.01116.32
7.3.180.0090.00916.57
7.3.170.0180.00016.68
7.3.160.0100.00716.43
7.2.330.0170.00716.36
7.2.320.0100.01316.81
7.2.310.0060.00916.68
7.2.300.0200.00416.83
7.2.290.0030.01416.75
7.2.60.0040.01116.68
7.2.00.0090.00319.42
7.1.200.0030.00715.76
7.1.100.0030.01017.78
7.1.70.0040.00417.15
7.1.60.0060.01819.40
7.1.50.0040.01116.90
7.1.00.0030.07722.45
7.0.200.0060.00316.58
7.0.140.0070.07022.08
7.0.60.0200.07719.93
7.0.50.0100.07717.98
7.0.40.0070.09019.96
7.0.30.0170.04320.23
7.0.20.0230.04020.32
7.0.10.0070.05720.24
7.0.00.0030.06320.06
5.6.280.0030.07320.87
5.6.210.0030.08320.54
5.6.200.0030.06318.18
5.6.190.0230.07320.47
5.6.180.3330.03320.55
5.6.170.0300.07320.61
5.6.160.0070.08720.47
5.6.150.0030.04018.28
5.6.140.0030.05018.29
5.6.130.0030.07718.17
5.6.120.0070.08320.91
5.6.110.0130.07720.95
5.6.100.0100.07721.02
5.6.90.0070.05721.08
5.6.80.0070.07020.51
5.6.70.4700.03020.51
5.5.350.0100.03020.39
5.5.340.0030.04318.03
5.5.330.0070.05320.27
5.5.320.0030.05320.30
5.5.310.0230.03720.34
5.5.300.0030.04017.97
5.5.290.0170.07717.93
5.5.280.0100.03720.82
5.5.270.0130.06320.87
5.5.260.0070.03720.72
5.5.250.0130.07720.61
5.5.240.0000.03320.19
5.4.450.4270.04019.45
5.4.440.0130.07319.40
5.4.430.1730.07019.25
5.4.420.4800.04719.25
5.4.410.4330.03019.45
5.4.400.0000.04019.07
5.4.390.4100.05019.14
5.4.380.3570.04018.98
5.4.370.3600.03319.25
5.4.360.2830.04018.98
5.4.350.3970.03319.21
5.4.340.4270.02718.95
5.4.320.0070.04719.22
5.4.310.3900.03719.12
5.4.300.4230.04319.13
5.4.290.4000.04319.24
5.4.280.4530.04319.16
5.4.270.3900.04018.94
5.4.260.4200.03719.25
5.4.250.4130.03019.21
5.4.240.4070.03319.03
5.4.230.4170.04319.09
5.4.220.3830.04318.93
5.4.210.3700.03318.92
5.4.200.3930.04018.98
5.4.190.4170.03319.02
5.4.180.4330.04319.25
5.4.170.4630.03319.09
5.4.160.3700.03718.90
5.4.150.4070.03719.19
5.4.140.4000.03316.49
5.4.130.3930.03716.30
5.4.120.3900.03316.39
5.4.110.3700.03716.47
5.4.100.3830.03316.45
5.4.90.4170.03716.48
5.4.80.4700.02316.55
5.4.70.4900.03016.52
5.4.60.4670.04016.52
5.4.50.4530.03716.45
5.4.40.4370.02016.49
5.4.30.3930.03716.48
5.4.20.3770.03716.32
5.4.10.3770.03716.42
5.4.00.3800.03315.93
5.3.290.2630.04314.68
5.3.280.4030.03014.61
5.3.270.3830.04014.66
5.3.260.4270.04014.64
5.3.250.3800.03314.53
5.3.240.3430.03714.67
5.3.230.3830.04014.60
5.3.220.3670.04014.56
5.3.210.3800.03314.46
5.3.200.4070.04014.56
5.3.190.4070.04014.60
5.3.180.4300.04014.57
5.3.170.4930.03714.46
5.3.160.3830.03314.62
5.3.150.4200.04014.62
5.3.140.4430.04014.59
5.3.130.3430.04014.44
5.3.120.4530.04014.73
5.3.110.4030.03714.59
5.3.100.3870.03714.07
5.3.90.4200.03714.17
5.3.80.4530.02714.17
5.3.70.3600.03714.06
5.3.60.4170.03314.01
5.3.50.4170.03313.96
5.3.40.3870.04013.92
5.3.30.4170.03713.95
5.3.20.3830.03313.71
5.3.10.4170.03313.61
5.3.00.3800.03013.64
5.2.170.3430.02711.15
5.2.160.3500.03011.19
5.2.150.3530.03011.16
5.2.140.3100.02711.21
5.2.130.3370.03011.14
5.2.120.3530.02311.03
5.2.110.3300.03011.26
5.2.100.2970.02311.11
5.2.90.3500.02711.11
5.2.80.3600.03310.99
5.2.70.3530.03311.06
5.2.60.3430.02711.00
5.2.50.3900.02711.02
5.2.40.2800.03011.04
5.2.30.3570.02010.97
5.2.20.2830.03310.97
5.2.10.2370.03310.75
5.2.00.1300.02710.86
5.1.60.2100.02310.04
5.1.50.1370.02310.06
5.1.40.2170.0279.91
5.1.30.2230.02710.35
5.1.20.3430.02310.51
5.1.10.2470.02710.21
5.1.00.1970.02310.12
5.0.50.1370.0208.70
5.0.40.0870.0208.43
5.0.30.1170.0308.27
5.0.20.1070.0178.16
5.0.10.1100.0208.24
5.0.00.1130.0338.13
4.4.90.1470.0175.89
4.4.80.1730.0175.85
4.4.70.1870.0135.80
4.4.60.1830.0135.76
4.4.50.1600.0175.86
4.4.40.0400.0235.87
4.4.30.0570.0135.84
4.4.20.1530.0135.83
4.4.10.0770.0135.90
4.4.00.0770.0235.86
4.3.110.1130.0135.76
4.3.100.0870.0135.76
4.3.90.1030.0175.79
4.3.80.1200.0235.67
4.3.70.1200.0135.76
4.3.60.1170.0135.72
4.3.50.1030.0175.82
4.3.40.0970.0305.68
4.3.30.0400.0135.62
4.3.20.0600.0175.62
4.3.10.0400.0135.62
4.3.00.0400.0135.62

preferences:
61.89 ms | 401 KiB | 5 Q