3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace JoshDiFabio; interface RomanNumeralGeneratorInterface { /** * @param int $number * @return string * @throws \InvalidArgumentException Argument not an integer or out of range * @author Josh Di Fabio <joshdifabio@hotmail.com> */ public function generate($number); } class RomanNumeral { const ONE = 'I'; const FIVE = 'V'; const TEN = 'X'; const FIFTY = 'L'; const ONE_HUNDRED = 'C'; const FIVE_HUNDRED = 'D'; const ONE_THOUSAND = 'M'; } class RomanNumeralGenerator implements RomanNumeralGeneratorInterface { /** * @var array * @author Josh Di Fabio <joshdifabio@hotmail.com> */ private $_integerNumeralMap = array( 1000 => RomanNumeral::ONE_THOUSAND, 500 => RomanNumeral::FIVE_HUNDRED, 100 => RomanNumeral::ONE_HUNDRED, 50 => RomanNumeral::FIFTY, 10 => RomanNumeral::TEN, 5 => RomanNumeral::FIVE, 1 => RomanNumeral::ONE, ); /** * @param int $number * @return string * @throws \InvalidArgumentException Argument not an integer or out of range * @author Josh Di Fabio <joshdifabio@hotmail.com> */ public function generate($number) { if (!is_integer($number)) { throw new \InvalidArgumentException('Provided argument is not an integer.'); } if (1 > $number || 3999 < $number) { throw new \InvalidArgumentException( 'The provided number is not within the allowed range of 1 to 3999.'); } $numerals = array(); while (0 < $number) { foreach ($this->_integerNumeralMap as $_integer => $_numeral) { if ($number >= $_integer) { $numerals[] = $_numeral; $number -= $_integer; break; } } } return implode('', $numerals); } } $generator = new RomanNumeralGenerator; echo $generator->generate(312);

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.0110.00718.56
8.3.50.0140.00521.92
8.3.40.0100.00718.67
8.3.30.0110.00719.02
8.3.20.0040.00420.46
8.3.10.0000.00821.95
8.3.00.0030.01222.29
8.2.180.0120.00316.75
8.2.170.0080.00622.96
8.2.160.0150.00021.08
8.2.150.0030.00524.18
8.2.140.0030.00624.66
8.2.130.0080.00026.16
8.2.120.0000.00819.36
8.2.110.0090.00022.31
8.2.100.0070.00417.72
8.2.90.0040.00419.34
8.2.80.0050.00317.97
8.2.70.0000.00817.63
8.2.60.0000.00818.03
8.2.50.0000.00818.07
8.2.40.0050.00818.09
8.2.30.0070.00018.04
8.2.20.0040.00417.63
8.2.10.0060.00317.88
8.2.00.0040.00417.77
8.1.280.0120.00325.92
8.1.270.0060.00323.79
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0090.00023.92
8.1.230.0110.00019.10
8.1.220.0040.00417.74
8.1.210.0080.00018.77
8.1.200.0060.00317.22
8.1.190.0080.00017.63
8.1.180.0080.00018.10
8.1.170.0030.00618.59
8.1.160.0000.00822.03
8.1.150.0030.00518.75
8.1.140.0070.00017.45
8.1.130.0000.00717.77
8.1.120.0000.00717.54
8.1.110.0000.00817.50
8.1.100.0030.00517.45
8.1.90.0000.00817.41
8.1.80.0000.00717.45
8.1.70.0000.00717.42
8.1.60.0030.00717.50
8.1.50.0000.00817.50
8.1.40.0070.00017.43
8.1.30.0040.00417.69
8.1.20.0040.00417.68
8.1.10.0000.00717.63
8.1.00.0040.00417.61
8.0.300.0000.00818.77
8.0.290.0060.00317.15
8.0.280.0030.00518.48
8.0.270.0000.00717.29
8.0.260.0070.00416.86
8.0.250.0070.00016.86
8.0.240.0040.00416.88
8.0.230.0000.00817.02
8.0.220.0000.00716.81
8.0.210.0030.00416.93
8.0.200.0000.00616.97
8.0.190.0040.00417.00
8.0.180.0050.00216.90
8.0.170.0030.00616.81
8.0.160.0000.00716.95
8.0.150.0070.00016.81
8.0.140.0040.00416.79
8.0.130.0000.00613.29
8.0.120.0040.00416.80
8.0.110.0000.00716.88
8.0.100.0000.00716.88
8.0.90.0040.00416.97
8.0.80.0130.00316.99
8.0.70.0070.00016.93
8.0.60.0040.00416.78
8.0.50.0040.00416.75
8.0.30.0120.00617.16
8.0.20.0100.00817.40
8.0.10.0040.00417.04
8.0.00.0090.00916.70
7.4.330.0020.00515.00
7.4.320.0000.00616.45
7.4.300.0060.00016.59
7.4.290.0070.00016.63
7.4.280.0000.00716.64
7.4.270.0000.00716.52
7.4.260.0000.00816.61
7.4.250.0050.00316.51
7.4.240.0040.00416.64
7.4.230.0030.00316.53
7.4.220.0090.00916.62
7.4.210.0090.00816.64
7.4.200.0000.00716.66
7.4.190.0000.00716.51
7.4.160.0030.01416.49
7.4.150.0090.00917.40
7.4.140.0110.00817.86
7.4.130.0110.00616.55
7.4.120.0110.00816.52
7.4.110.0110.00716.83
7.4.100.0140.00416.49
7.4.90.0090.01016.49
7.4.80.0090.00916.45
7.4.70.0060.01316.48
7.4.60.0130.00916.63
7.4.50.0060.00316.46
7.4.40.0070.00822.77
7.4.30.0030.01516.45
7.4.10.0160.00014.68
7.4.00.0070.01014.95
7.3.330.0030.00313.25
7.3.320.0000.00513.20
7.3.310.0040.00416.49
7.3.300.0040.00416.40
7.3.290.0030.01016.49
7.3.280.0090.00816.39
7.3.270.0090.00917.40
7.3.260.0260.01616.66
7.3.250.0080.01016.43
7.3.240.0100.00716.46
7.3.230.0110.00416.39
7.3.210.0140.00316.55
7.3.200.0110.00919.39
7.3.190.0120.01216.42
7.3.180.0060.01016.55
7.3.170.0060.01316.38
7.3.160.0130.00316.61
7.3.130.0080.01115.00
7.3.120.0050.01115.02
7.3.110.0060.01215.14
7.3.100.0030.01014.71
7.3.90.0100.00315.05
7.3.80.0060.00614.87
7.3.70.0040.00514.79
7.3.60.0030.01014.82
7.3.50.0060.00314.84
7.3.40.0040.00414.77
7.3.30.0030.01214.98
7.3.20.0070.00816.81
7.3.10.0030.01116.53
7.3.00.0130.00016.69
7.2.330.0100.00716.77
7.2.320.0090.00916.72
7.2.310.0040.01216.87
7.2.300.0070.01016.87
7.2.290.0140.00316.71
7.2.260.0060.01315.10
7.2.250.0030.01615.18
7.2.240.0100.00714.68
7.2.230.0040.00414.84
7.2.220.0030.01314.95
7.2.210.0000.01415.05
7.2.200.0060.00915.22
7.2.190.0090.00615.12
7.2.180.0070.01015.20
7.2.170.0000.01515.13
7.2.160.0070.00715.24
7.2.150.0090.00616.97
7.2.140.0030.00917.00
7.2.130.0090.00617.13
7.2.120.0040.01116.80
7.2.110.0030.01316.81
7.2.100.0100.00616.77
7.2.90.0080.00817.04
7.2.80.0120.00316.93
7.2.70.0030.01016.88
7.2.60.0040.01116.92
7.2.50.0090.00617.02
7.2.40.0030.01016.82
7.2.30.0030.01216.84
7.2.20.0000.01116.97
7.2.10.0050.00516.92
7.2.00.0030.01018.12
7.1.330.0120.00315.81
7.1.320.0030.00616.05
7.1.310.0040.01215.55
7.1.300.0130.00315.64
7.1.290.0070.00415.89
7.1.280.0090.00615.61
7.1.270.0070.00715.88
7.1.260.0060.01015.95
7.1.250.0040.01215.60
7.1.240.0100.00615.58
7.1.230.0080.00315.95
7.1.220.0030.01415.91
7.1.210.0000.00915.87
7.1.200.0070.00315.68
7.1.190.0090.00015.89
7.1.180.0060.00915.94
7.1.170.0000.01615.62
7.1.160.0100.00315.74
7.1.150.0030.01115.91
7.1.140.0000.01115.53
7.1.130.0030.01015.69
7.1.120.0000.01415.90
7.1.110.0110.00315.96
7.1.100.0020.00817.10
7.1.90.0070.00315.86
7.1.80.0030.01015.57
7.1.70.0030.00716.47
7.1.60.0050.01317.83
7.1.50.0050.00616.47
7.1.40.0030.00615.53
7.1.30.0000.01315.84
7.1.20.0110.00015.82
7.1.10.0060.00615.75
7.1.00.0040.04118.96
7.0.330.0070.00715.63
7.0.320.0030.01015.46
7.0.310.0030.01015.52
7.0.300.0030.01015.45
7.0.290.0110.00415.51
7.0.280.0060.00615.47
7.0.270.0060.00315.61
7.0.260.0030.01015.37
7.0.250.0000.01415.44
7.0.240.0040.00715.49
7.0.230.0030.00815.36
7.0.220.0070.00315.59
7.0.210.0000.00815.45
7.0.200.0020.01216.07
7.0.190.0030.00715.41
7.0.180.0070.00715.57
7.0.170.0000.01315.57
7.0.160.0060.00615.55
7.0.150.0080.00615.16
7.0.140.0050.03818.60
7.0.130.0070.00315.22
7.0.120.0040.00715.24
7.0.110.0030.00715.55
7.0.100.0100.04017.61
7.0.90.0070.04517.71
7.0.80.0150.03717.75
7.0.70.0060.03317.59
7.0.60.0150.03517.67
7.0.50.0150.05017.88
7.0.40.0050.04516.86
7.0.30.0120.04516.74
7.0.20.0100.02316.73
7.0.10.0100.02316.76
7.0.00.0080.03216.69
5.6.400.0030.00714.64
5.6.390.0090.00614.33
5.6.380.0080.00814.73
5.6.370.0060.00614.61
5.6.360.0000.01414.52
5.6.350.0060.00614.51
5.6.340.0000.01414.75
5.6.330.0080.00614.74
5.6.320.0120.00014.54
5.6.310.0030.00814.80
5.6.300.0040.01114.38
5.6.290.0000.01114.30
5.6.280.0030.04017.79
5.6.270.0090.00014.34
5.6.260.0120.00314.21
5.6.250.0080.04817.67
5.6.240.0110.03117.60
5.6.230.0090.03617.55
5.6.220.0080.04217.58
5.6.210.0170.03817.57
5.6.200.0030.04717.62
5.6.190.0060.03517.75
5.6.180.0020.05017.70
5.6.170.0040.04217.79
5.6.160.0020.02817.80
5.6.150.0060.02517.78
5.6.140.0030.02717.70
5.6.130.0080.02017.76
5.6.120.0030.02717.70
5.6.110.0070.02617.88
5.6.100.0030.02517.78
5.6.90.0040.02617.74
5.6.80.0030.02417.39
5.6.70.0080.01717.41
5.6.60.0060.02217.47
5.6.50.0050.02017.46
5.6.40.0090.02017.45
5.6.30.0090.01717.29
5.6.20.0080.02017.31
5.6.10.0050.02517.45
5.6.00.0070.02117.25
5.5.380.0110.04117.52
5.5.370.0080.03817.26
5.5.360.0040.04617.48
5.5.350.0080.04517.47
5.5.340.0100.03017.69
5.5.330.0050.04517.71
5.5.320.0060.03517.41
5.5.310.0150.02817.74
5.5.300.0050.02217.67
5.5.290.0090.02317.70
5.5.280.0020.02717.54
5.5.270.0070.02317.78
5.5.260.0050.02217.53
5.5.250.0020.02817.52
5.5.240.0070.02017.25
5.5.230.0030.03817.27
5.5.220.0010.02917.29
5.5.210.0100.02017.21
5.5.200.0030.02317.21
5.5.190.0030.02417.17
5.5.180.0080.02317.34
5.5.170.0110.00414.05
5.5.160.0030.03117.27
5.5.150.0060.03517.14
5.5.140.0050.02417.33
5.5.130.0050.02217.38
5.5.120.0020.02617.43
5.5.110.0050.02017.26
5.5.100.0090.02017.26
5.5.90.0070.02517.23
5.5.80.0030.02317.23
5.5.70.0030.02817.20
5.5.60.0090.02517.24
5.5.50.0050.02517.29
5.5.40.0030.02517.15
5.5.30.0050.03017.18
5.5.20.0050.02317.21
5.5.10.0100.04217.31
5.5.00.0070.03017.22
5.4.450.0050.02015.98
5.4.440.0050.02215.97
5.4.430.0030.02415.93
5.4.420.0010.02615.94
5.4.410.0020.02715.89
5.4.400.0050.03615.74
5.4.390.0080.01515.75
5.4.380.0080.02015.75
5.4.370.0050.02015.73
5.4.360.0050.02015.76
5.4.350.0060.02715.63
5.4.340.0000.02315.78
5.4.330.0070.00712.42
5.4.320.0050.02215.81
5.4.310.0070.01515.68
5.4.300.0060.02115.72
5.4.290.0070.02015.73
5.4.280.0040.02415.79
5.4.270.0030.02015.82
5.4.260.0020.02215.82
5.4.250.0020.03115.72
5.4.240.0080.01515.76
5.4.230.0070.01815.81
5.4.220.0050.02415.78
5.4.210.0000.02515.68
5.4.200.0000.04815.75
5.4.190.0040.03215.79
5.4.180.0080.02715.76
5.4.170.0070.03115.72
5.4.160.0050.03215.62
5.4.150.0020.04415.64
5.4.140.0030.03214.46
5.4.130.0070.04014.46
5.4.120.0120.03314.44
5.4.110.0020.03314.43
5.4.100.0020.04014.49
5.4.90.0090.03414.47
5.4.80.0050.02014.41
5.4.70.0080.03714.48
5.4.60.0070.03414.37
5.4.50.0060.03014.39
5.4.40.0050.03714.38
5.4.30.0120.02614.43
5.4.20.0030.02814.44
5.4.10.0100.03814.45
5.4.00.0100.03514.16
5.3.290.0000.02413.56
5.3.280.0020.02413.50
5.3.270.0060.04213.54
5.3.260.0050.04113.48
5.3.250.0060.03813.50
5.3.240.0070.04013.52
5.3.230.0030.03513.50
5.3.220.0070.03513.56
5.3.210.0070.03813.53
5.3.200.0070.03713.50
5.3.190.0070.03013.48
5.3.180.0040.03313.51
5.3.170.0050.02213.52
5.3.160.0040.03913.55
5.3.150.0030.03213.52
5.3.140.0040.02313.53
5.3.130.0020.03113.46
5.3.120.0100.03713.45
5.3.110.0090.03413.55
5.3.100.0060.03813.23
5.3.90.0050.03213.29
5.3.80.0100.03313.27
5.3.70.0060.02113.23
5.3.60.0050.03313.28
5.3.50.0080.03313.25
5.3.40.0000.04313.19
5.3.30.0050.02213.12
5.3.20.0070.01913.05
5.3.10.0020.03813.04
5.3.00.0050.02313.09
5.2.170.0030.06311.20
5.2.160.0070.05311.11
5.2.150.0030.06311.00
5.2.140.0070.05710.98
5.2.130.0070.04710.92
5.2.120.0000.05311.02
5.2.110.0070.05310.93
5.2.100.0000.07011.10
5.2.90.0000.05711.15
5.2.80.0030.03711.13
5.2.70.0000.03711.02
5.2.60.0200.04310.96
5.2.50.0030.07011.05
5.2.40.0030.06011.04
5.2.30.0030.04010.76
5.2.20.0030.06310.94
5.2.10.0030.04310.88
5.2.00.0100.05310.66
5.1.60.0030.05310.02
5.1.50.0070.05010.01
5.1.40.0030.0279.96
5.1.30.0030.04310.35
5.1.20.0070.05310.41
5.1.10.0070.0339.95
5.1.00.0000.05310.16
5.0.50.0030.0208.94
5.0.40.0170.0338.94
5.0.30.0070.0608.94
5.0.20.0030.0438.94
5.0.10.0070.0278.94
5.0.00.0030.0438.94
4.4.90.0000.0378.94
4.4.80.0070.0238.94
4.4.70.0000.0378.94
4.4.60.0030.0338.94
4.4.50.0030.0338.94
4.4.40.0030.0508.94
4.4.30.0030.0278.94
4.4.20.0100.0238.94
4.4.10.0000.0208.94
4.4.00.0030.0478.94
4.3.110.0000.0408.94
4.3.100.0030.0308.94
4.3.90.0070.0308.94
4.3.80.0030.0538.94
4.3.70.0000.0178.94
4.3.60.0000.0378.94
4.3.50.0000.0378.94
4.3.40.0030.0508.94
4.3.30.0000.0308.94
4.3.20.0000.0338.94
4.3.10.0000.0308.94
4.3.00.0100.0178.94

preferences:
49.1 ms | 401 KiB | 5 Q