3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Roman { public $dividorsBelowTen = [0 => "", 1 => "I", 2 => "II", 3 => "III", 4 => "IV", 5 => "V", 6 => "VI", 7 => "VII", 8 => "VIII", 9 => "IX"]; public $dividorsTen = [0 => "", 1 => "X", 2 => "XX", 3 => "XXX", 4 => "XL", 5 => "L", 6 => "LX", 7 => "LXX", 8 => "LXXX", 9 => "XC"];   public $dividorsHundreds = [0 => "", 1 => "C", 2 => "CC", 3 => "CCC", 4 => "CD", 5 => "D", 6 => "DC", 7 => "DCC", 8 => "DCCC", 9 => "CM",]; public $dividorsThousands = [1 => "M", 2 => "MM", 3 => "MMM", 4 => "MMMM"]; public function transform($in) { if ($in >= 1000) { $thousand = (int)($in / 1000); $hundreds = (int)(($in - $thousand * 1000) / 100); $tens = (int)(($in - $thousand * 1000 - $hundreds * 100) / 10); $once = ($in - $thousand * 1000 - $hundreds * 100 - $tens * 10); return $this->dividorsThousands[$thousand] . $this->dividorsHundreds[$hundreds] . $this->dividorsTen[$tens] . $this->dividorsBelowTen[$once]; } else if ($in >= 100) { $hundreds = (int)($in / 100); $tens = (int)(($in - $hundreds * 100) / 10); $once = ($in - $hundreds * 100 - $tens * 10); return $this->dividorsHundreds[$hundreds] . $this->dividorsTen[$tens] . $this->dividorsBelowTen[$once]; } else if ($in >= 10) { $once = $in % 10; $tens = (int)($in / 10); return $this->dividorsTen[$tens] . $this->dividorsBelowTen[$once]; } else { return $this->dividorsBelowTen[$in]; } } } $r = new Roman(); for ($i = 1; $i < 5000; $i++) { $r->transform($i); }

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)
5.4.320.0080.03712.51
5.4.310.0070.03912.51
5.4.300.0100.04012.51
5.4.290.0100.03712.51
5.4.280.0110.04512.40
5.4.270.0130.04312.41
5.4.260.0060.03712.40
5.4.250.0070.03712.41
5.4.240.0040.03712.40
5.4.230.0050.03912.40
5.4.220.0080.04712.40
5.4.210.0110.03812.39
5.4.200.0090.04612.40
5.4.190.0080.04012.39
5.4.180.0120.03012.39
5.4.170.0070.04712.40
5.4.160.0060.03712.39
5.4.150.0070.04312.39
5.4.140.0070.03912.09
5.4.130.0080.04212.06
5.4.120.0090.03812.04
5.4.110.0050.04012.02
5.4.100.0090.04512.03
5.4.90.0120.04212.03
5.4.80.0070.04112.03
5.4.70.0100.03712.02
5.4.60.0110.03412.02
5.4.50.0120.03312.02
5.4.40.0080.04112.01
5.4.30.0070.03412.01
5.4.20.0120.03212.00
5.4.10.0110.03212.01
5.4.00.0070.04211.50
5.3.290.0060.04812.80
5.3.280.0060.03812.71
5.3.270.0060.04312.73
5.3.260.0110.03812.72
5.3.250.0080.03812.71
5.3.240.0080.04312.72
5.3.230.0120.03612.71
5.3.220.0080.03412.68
5.3.210.0090.04112.68
5.3.200.0060.03912.68
5.3.190.0100.04112.68
5.3.180.0040.03812.67
5.3.170.0070.04212.67
5.3.160.0130.04312.67
5.3.150.0060.03712.67
5.3.140.0070.04012.66
5.3.130.0110.04412.66
5.3.120.0090.04412.66
5.3.110.0090.04212.66
5.3.100.0060.04412.12
5.3.90.0060.03612.10
5.3.80.0080.03512.09
5.3.70.0080.04112.09
5.3.60.0100.03912.08
5.3.50.0080.03512.02
5.3.40.0060.03512.02
5.3.30.0100.03011.98
5.3.20.0060.04211.76
5.3.10.0100.03011.73
5.3.00.0060.03611.71
5.2.170.0060.0349.22
5.2.160.0060.0289.21
5.2.150.0090.0339.21
5.2.140.0060.0329.21
5.2.130.0070.0349.18
5.2.120.0090.0309.18
5.2.110.0070.0349.18
5.2.100.0060.0359.18
5.2.90.0070.0279.17
5.2.80.0050.0349.17
5.2.70.0100.0319.17
5.2.60.0060.0389.13
5.2.50.0050.0309.10
5.2.40.0040.0299.07
5.2.30.0020.0319.05
5.2.20.0060.0279.04
5.2.10.0030.0298.94
5.2.00.0040.0298.80
5.1.60.0020.0288.09
5.1.50.0020.0268.09
5.1.40.0040.0268.06
5.1.30.0070.0338.41
5.1.20.0070.0298.43
5.1.10.0050.0358.16
5.1.00.0030.0338.16
5.0.50.0050.0246.64
5.0.40.0070.0226.50
5.0.30.0070.0356.30
5.0.20.0020.0236.28
5.0.10.0030.0276.26
5.0.00.0040.0316.25
4.4.90.0040.0144.78
4.4.80.0020.0164.75
4.4.70.0020.0164.76
4.4.60.0040.0144.75
4.4.50.0020.0164.77
4.4.40.0010.0264.71
4.4.30.0040.0144.75
4.4.20.0010.0174.84
4.4.10.0030.0154.84
4.4.00.0000.0284.75
4.3.110.0030.0164.67
4.3.100.0040.0134.67
4.3.90.0030.0144.64
4.3.80.0020.0244.58
4.3.70.0020.0154.63
4.3.60.0030.0164.63
4.3.50.0030.0224.63
4.3.40.0030.0304.54
4.3.30.0020.0223.30
4.3.20.0020.0203.28
4.3.10.0040.0163.24
4.3.00.0030.01714.28

preferences:
141.07 ms | 1386 KiB | 7 Q