3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getColor($rgb) { $colors = array(BLUE =>0x0a9ef3, RED => 0xea0a2f, GREEN => 0x336633); $largestDiff = 0; $closestColor = ""; foreach ($colors as $name => $rgbColor) { if (!isset($smallestDiff)) { $smallestDiff = colorDiff($rgbColor,$rgb); $closestColor = $name; } else if (colorDiff($rgbColor,$rgb) < $smallestDiff) { $smallestDiff = colorDiff($rgbColor,$rgb); $closestColor = $name; } } return $closestColor; } function colorDiff($rgb1,$rgb2) { // do the math on each tuple $red1 = hexdec(substr($rgb1,0,2)); $green1 = hexdec(substr($rgb1,2,2)); $blue1 = hexdec(substr($rgb1,4,2)); $red2 = hexdec(substr($rgb2,0,2)); $green2 = hexdec(substr($rgb2,2,2)); $blue2 = hexdec(substr($rgb2,4,2)); return abs($red1 - $red2) + abs($green1 - $green2) + abs($blue1 - $blue2) ; } $color = '336633'; $closestmatch = getColor("0x".$color); echo $closematch; ?>

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.40.0120.00618.88
8.3.30.0070.00720.41
8.3.20.0050.00320.22
8.3.10.0070.00021.27
8.3.00.0000.00822.34
8.2.170.0110.00322.96
8.2.160.0100.00720.36
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00420.80
8.2.110.0120.00019.20
8.2.100.0030.00917.84
8.2.90.0000.00819.27
8.2.80.0050.00318.05
8.2.70.0040.00417.63
8.2.60.0090.00017.80
8.2.50.0030.00618.07
8.2.40.0030.00618.07
8.2.30.0070.00019.40
8.2.20.0040.00417.74
8.2.10.0040.00417.79
8.2.00.0040.00417.72
8.1.270.0050.00323.99
8.1.260.0000.00826.35
8.1.250.0000.00828.09
8.1.240.0030.00622.46
8.1.230.0110.00020.95
8.1.220.0000.00818.77
8.1.210.0060.00320.87
8.1.200.0070.00317.35
8.1.190.0040.00417.53
8.1.180.0030.00518.10
8.1.170.0040.00418.46
8.1.160.0040.00418.92
8.1.150.0000.00718.66
8.1.140.0000.00717.48
8.1.130.0030.00317.80
8.1.120.0000.00717.42
8.1.110.0000.00817.38
8.1.100.0070.00017.37
8.1.90.0040.00417.46
8.1.80.0030.00717.32
8.1.70.0070.00017.42
8.1.60.0000.00817.64
8.1.50.0060.00317.56
8.1.40.0020.00517.52
8.1.30.0080.00017.63
8.1.20.0040.00417.68
8.1.10.0000.00817.57
8.1.00.0040.00417.52
8.0.300.0030.00620.04
8.0.290.0020.00517.18
8.0.280.0000.00718.54
8.0.270.0050.00217.21
8.0.260.0030.00516.92
8.0.250.0020.00517.09
8.0.240.0030.00617.07
8.0.230.0000.00816.91
8.0.220.0030.00317.01
8.0.210.0030.00316.93
8.0.200.0030.00316.93
8.0.190.0040.00416.93
8.0.180.0040.00416.96
8.0.170.0040.00416.89
8.0.160.0040.00416.90
8.0.150.0000.00716.93
8.0.140.0070.00717.00
8.0.130.0000.00513.45
8.0.120.0030.00517.00
8.0.110.0040.00416.97
8.0.100.0040.00416.94
8.0.90.0000.00716.80
8.0.80.0060.00917.02
8.0.70.0000.00716.87
8.0.60.0080.00017.02
8.0.50.0000.00717.09
8.0.30.0080.01117.18
8.0.20.0160.01017.40
8.0.10.0040.00417.09
8.0.00.0090.01116.95
7.4.330.0030.00316.83
7.4.320.0070.00016.55
7.4.300.0000.00716.45
7.4.290.0030.00316.52
7.4.280.0070.00016.58
7.4.270.0040.00416.69
7.4.260.0050.00313.23
7.4.250.0050.00316.59
7.4.240.0020.00516.54
7.4.230.0000.00716.71
7.4.220.0150.00316.68
7.4.210.0090.00916.58
7.4.200.0070.00016.54
7.4.190.0050.00316.80
7.4.160.0060.01316.63
7.4.150.0130.01317.40
7.4.140.0070.01017.86
7.4.130.0120.00816.59
7.4.120.0060.01016.48
7.4.110.0130.00316.42
7.4.100.0140.00316.66
7.4.90.0110.00716.60
7.4.80.0110.00619.39
7.4.70.0000.01716.48
7.4.60.0100.00616.57
7.4.50.0060.00316.30
7.4.40.0060.00922.77
7.4.30.0140.00316.63
7.4.00.0110.00715.19
7.3.330.0030.00313.48
7.3.320.0060.00013.55
7.3.310.0030.00316.49
7.3.300.0070.00016.32
7.3.290.0090.00616.39
7.3.280.0090.00816.49
7.3.270.0100.01617.40
7.3.260.0130.00618.24
7.3.250.0080.01216.42
7.3.240.0130.00416.57
7.3.230.0060.01116.48
7.3.210.0110.00616.48
7.3.200.0140.00519.39
7.3.190.0090.01216.45
7.3.180.0100.00716.46
7.3.170.0000.01616.60
7.3.160.0070.01016.46
7.3.120.0100.00714.87
7.3.110.0060.01114.98
7.3.100.0100.00814.81
7.3.90.0100.00714.88
7.3.80.0090.00814.85
7.3.70.0040.01114.74
7.3.60.0070.00614.81
7.3.50.0060.00814.88
7.3.40.0020.01314.80
7.3.30.0070.00814.75
7.3.20.0050.00816.63
7.3.10.0060.00716.63
7.3.00.0080.00716.69
7.2.330.0180.00016.83
7.2.320.0170.01016.78
7.2.310.0230.00016.79
7.2.300.0110.00516.93
7.2.290.0070.01016.81
7.2.250.0110.00615.02
7.2.240.0090.00815.18
7.2.230.0070.00915.13
7.2.220.0040.01115.08
7.2.210.0080.00715.06
7.2.200.0060.01015.02
7.2.190.0060.00615.03
7.2.180.0050.00915.07
7.2.170.0060.00815.05
7.2.160.0050.01114.84
7.2.150.0110.00317.07
7.2.140.0050.01016.83
7.2.130.0090.00716.88
7.2.120.0060.00816.88
7.2.110.0100.00516.89
7.2.100.0100.00516.89
7.2.90.0060.01016.88
7.2.80.0070.00817.01
7.2.70.0130.00316.95
7.2.60.0060.00816.93
7.2.50.0050.01117.06
7.2.40.0050.01016.98
7.2.30.0060.00816.93
7.2.20.0050.00916.82
7.2.10.0090.00517.04
7.2.00.0050.00917.69
7.1.330.0080.00715.96
7.1.320.0090.00515.74
7.1.310.0090.00415.75
7.1.300.0060.00715.79
7.1.290.0040.00915.94
7.1.280.0070.00915.68
7.1.270.0050.00615.82
7.1.260.0030.01015.87
7.1.250.0060.00815.89
7.1.200.0000.01415.89
7.1.100.0000.01217.96
7.1.70.0040.00817.23
7.1.60.0090.00919.17
7.1.50.0070.00317.15
7.1.00.0030.03322.51
7.0.200.0040.00716.89
7.0.140.0100.07022.00
7.0.90.0070.09020.07
7.0.80.0000.05719.87
7.0.70.0000.07319.93
7.0.60.0300.07320.07
7.0.50.0170.07720.39
7.0.40.0170.03320.09
7.0.30.0000.05720.02
7.0.20.0030.07020.11
7.0.10.0070.07020.03
7.0.00.0100.07720.14
5.6.280.0000.07721.07
5.6.230.0130.07720.64
5.6.220.0130.07020.62
5.6.210.0070.08020.69
5.6.200.0070.07321.03
5.6.190.0070.08321.14
5.6.180.0030.04721.04
5.6.170.0300.06321.11
5.6.160.0100.08021.18
5.6.150.0070.08321.14
5.6.140.0170.06721.05
5.6.130.0100.06321.11
5.6.120.0130.07721.11
5.6.110.0100.07021.17
5.6.100.0130.03720.96
5.6.90.0000.05021.03
5.6.80.0000.08720.35
5.6.70.0170.04020.48
5.6.60.0030.04320.38
5.6.50.0030.04720.35
5.6.40.0030.05320.41
5.6.30.0000.07320.38
5.6.20.0070.08320.52
5.6.10.0200.06020.41
5.6.00.0070.07320.43
5.5.370.0200.06720.43
5.5.360.0070.06320.45
5.5.350.0030.06720.43
5.5.340.0100.07020.90
5.5.330.0100.07720.79
5.5.320.0170.07020.75
5.5.310.0130.07020.84
5.5.300.0030.08320.64
5.5.290.0100.06720.92
5.5.280.0100.08720.84
5.5.270.0000.08720.63
5.5.260.0100.04720.79
5.5.250.0130.06720.72
5.5.240.0130.04020.30
5.5.230.0130.07020.29
5.5.220.0200.05720.18
5.5.210.0070.04720.25
5.5.200.0130.03720.20
5.5.190.0000.08320.19
5.5.180.0070.05320.25
5.5.160.0100.05720.22
5.5.150.0130.07019.98
5.5.140.0100.06720.27
5.5.130.0100.07320.24
5.5.120.0070.04320.08
5.5.110.0170.06720.21
5.5.100.0000.05020.08
5.5.90.0170.06019.98
5.5.80.0170.04719.98
5.5.70.0030.04720.15
5.5.60.0000.04320.06
5.5.50.0100.05720.11
5.5.40.0100.08020.14
5.5.30.0070.07720.00
5.5.20.0130.06720.16
5.5.10.0230.05720.04
5.5.00.0130.06720.05
5.4.450.0030.06019.46
5.4.440.0170.07019.23
5.4.430.0130.06019.50
5.4.420.0100.08019.39
5.4.410.0030.06019.36
5.4.400.0030.07018.88
5.4.390.0070.05019.01
5.4.380.0170.05719.16
5.4.370.0000.04719.18
5.4.360.0170.06319.14
5.4.350.0070.07718.85
5.4.340.0030.05319.12
5.4.320.0170.06019.23
5.4.310.0130.06319.12
5.4.300.0030.06719.12
5.4.290.0100.06719.23
5.4.280.0070.06719.04
5.4.270.0030.06018.89
5.4.260.0000.05318.82
5.4.250.0130.06319.14
5.4.240.0100.03719.16
5.4.230.0100.07319.04
5.4.220.0000.05319.12
5.4.210.0170.06719.04
5.4.200.0030.08019.17
5.4.190.0070.05319.03
5.4.180.0070.06019.11
5.4.170.0170.07018.85
5.4.160.0030.08019.14
5.4.150.0000.05319.01
5.4.140.0070.03716.47
5.4.130.0070.07716.30
5.4.120.0170.06016.50
5.4.110.0130.06316.40
5.4.100.0100.07016.48
5.4.90.0130.06716.41
5.4.80.0100.03316.47
5.4.70.0030.07316.30
5.4.60.0070.05716.47
5.4.50.0070.05016.33
5.4.40.0130.06016.55
5.4.30.0030.08016.36
5.4.20.0170.03016.36
5.4.10.0070.07016.38
5.4.00.0070.07715.86
5.3.290.0070.08314.70
5.3.280.0000.07014.72
5.3.270.0030.06714.70
5.3.260.0070.07314.67
5.3.250.0070.07014.73
5.3.240.0070.07014.70
5.3.230.0000.05714.59
5.3.220.0100.06714.56
5.3.210.0030.08014.55
5.3.200.0100.08014.55
5.3.190.0030.08014.71
5.3.180.0070.07314.52
5.3.170.0170.03714.56
5.3.160.0070.06714.62
5.3.150.0070.07014.58
5.3.140.0100.06014.52
5.3.130.0070.07314.51
5.3.120.0070.07714.50
5.3.110.0030.07314.58
5.3.100.0030.07314.17
5.3.90.0030.05714.08
5.3.80.0000.06013.91
5.3.70.0100.07014.04
5.3.60.0130.05014.02
5.3.50.0070.04313.97
5.3.40.0100.04014.02
5.3.30.0130.06313.92
5.3.20.0070.05313.75
5.3.10.0030.04313.68
5.3.00.0070.04313.70
5.2.170.0030.06013.68
5.2.160.0070.03013.68
5.2.150.0000.07013.68
5.2.140.0070.03013.68
5.2.130.0070.05313.68
5.2.120.0000.04313.68
5.2.110.0030.06013.68
5.2.100.0070.05013.68
5.2.90.0070.03713.68
5.2.80.0130.04713.68
5.2.70.0030.06313.68
5.2.60.0070.04013.68
5.2.50.0100.03713.68
5.2.40.0100.05313.68
5.2.30.0070.04013.68
5.2.20.0030.05713.68
5.2.10.0070.05313.68
5.2.00.0100.06013.68
5.1.60.0070.05313.68
5.1.50.0030.04313.68
5.1.40.0030.06313.68
5.1.30.0070.04013.68
5.1.20.0070.05713.68
5.1.10.0100.05013.68
5.1.00.0000.05713.68
5.0.50.0030.03713.68
5.0.40.0070.04013.68
5.0.30.0000.07713.68
5.0.20.0000.03313.68
5.0.10.0070.04013.68
5.0.00.0000.03713.68
4.4.90.0030.03013.68
4.4.80.0000.03313.68
4.4.70.0100.02713.68
4.4.60.0030.03013.68
4.4.50.0030.03713.68
4.4.40.0030.04713.68
4.4.30.0100.02013.68
4.4.20.0030.03313.68
4.4.10.0070.03313.68
4.4.00.0000.05313.68
4.3.110.0000.03013.68
4.3.100.0070.03013.68
4.3.90.0030.02713.68
4.3.80.0000.05313.68
4.3.70.0100.02713.68
4.3.60.0000.01713.68
4.3.50.0070.02013.68
4.3.40.0000.02713.68
4.3.30.0000.03313.68
4.3.20.0000.02713.68
4.3.10.0000.03013.68
4.3.00.0000.02713.68

preferences:
47.03 ms | 400 KiB | 5 Q