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.0070.03712.51
5.4.310.0080.03812.51
5.4.300.0090.04112.51
5.4.290.0090.03912.50
5.4.280.0090.03412.41
5.4.270.0120.04012.40
5.4.260.0070.03812.41
5.4.250.0050.03812.40
5.4.240.0070.03412.40
5.4.230.0080.03512.39
5.4.220.0090.03212.39
5.4.210.0100.03612.39
5.4.200.0110.04312.39
5.4.190.0100.03512.39
5.4.180.0090.03712.39
5.4.170.0090.04512.40
5.4.160.0060.04412.40
5.4.150.0060.03612.39
5.4.140.0060.04112.08
5.4.130.0080.03412.07
5.4.120.0060.03512.03
5.4.110.0100.03312.02
5.4.100.0080.03312.02
5.4.90.0060.04012.02
5.4.80.0080.03512.03
5.4.70.0080.03312.02
5.4.60.0040.03612.02
5.4.50.0070.03312.02
5.4.40.0090.04512.01
5.4.30.0090.03212.01
5.4.20.0080.03312.00
5.4.10.0090.03212.00
5.4.00.0060.03911.50
5.3.290.0060.04012.80
5.3.280.0080.03612.70
5.3.270.0070.03812.73
5.3.260.0090.03512.72
5.3.250.0040.04012.72
5.3.240.0070.03612.72
5.3.230.0120.03212.70
5.3.220.0040.03912.68
5.3.210.0060.03912.68
5.3.200.0100.04412.68
5.3.190.0060.03712.68
5.3.180.0080.04112.68
5.3.170.0090.03312.67
5.3.160.0050.03812.68
5.3.150.0080.03512.67
5.3.140.0070.03512.66
5.3.130.0050.03912.66
5.3.120.0040.04212.65
5.3.110.0050.04112.66
5.3.100.0070.03912.12
5.3.90.0100.03212.10
5.3.80.0080.03712.09
5.3.70.0040.03812.09
5.3.60.0080.03412.08
5.3.50.0090.03312.02
5.3.40.0030.04012.02
5.3.30.0080.04011.98
5.3.20.0110.04211.78
5.3.10.0080.03911.73
5.3.00.0050.03711.71
5.2.170.0040.0319.21
5.2.160.0080.0299.22
5.2.150.0080.0289.22
5.2.140.0070.0299.21
5.2.130.0080.0259.18
5.2.120.0050.0289.18
5.2.110.0060.0289.18
5.2.100.0050.0289.17
5.2.90.0070.0279.18
5.2.80.0040.0359.17
5.2.70.0020.0329.17
5.2.60.0040.0349.13
5.2.50.0040.0319.10
5.2.40.0050.0289.07
5.2.30.0060.0289.05
5.2.20.0050.0309.04
5.2.10.0040.0298.94
5.2.00.0080.0298.80
5.1.60.0070.0258.09
5.1.50.0050.0258.09
5.1.40.0050.0258.07
5.1.30.0070.0248.41
5.1.20.0040.0278.43
5.1.10.0070.0248.17
5.1.00.0040.0258.16
5.0.50.0030.0216.64
5.0.40.0040.0196.50
5.0.30.0030.0316.31
5.0.20.0030.0216.28
5.0.10.0030.0216.26
5.0.00.0030.0316.25
4.4.90.0040.0154.78
4.4.80.0080.0154.75
4.4.70.0040.0144.76
4.4.60.0030.0164.76
4.4.50.0020.0164.77
4.4.40.0040.0254.71
4.4.30.0040.0144.75
4.4.20.0040.0144.85
4.4.10.0030.0154.85
4.4.00.0050.0234.76
4.3.110.0030.0154.67
4.3.100.0030.0154.66
4.3.90.0030.0144.64
4.3.80.0010.0264.58
4.3.70.0020.0154.63
4.3.60.0040.0124.63
4.3.50.0020.0204.63
4.3.40.0040.0224.54
4.3.30.0010.0173.30
4.3.20.0020.0163.28
4.3.10.0020.0163.23
4.3.00.0000.01314.28

preferences:
136.11 ms | 1398 KiB | 7 Q