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.60.0080.01218.68
8.3.50.0120.00621.15
8.3.40.0040.01118.78
8.3.30.0070.00720.22
8.3.20.0040.00420.35
8.3.10.0050.00321.08
8.3.00.0000.00822.21
8.2.180.0170.00316.63
8.2.170.0100.00722.96
8.2.160.0100.00322.08
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0040.00420.80
8.2.110.0100.00021.04
8.2.100.0090.00318.03
8.2.90.0090.00019.40
8.2.80.0080.00018.05
8.2.70.0060.00317.63
8.2.60.0030.00517.80
8.2.50.0040.00418.07
8.2.40.0040.00418.28
8.2.30.0000.00719.48
8.2.20.0000.00717.82
8.2.10.0000.00817.72
8.2.00.0040.00417.79
8.1.280.0090.00625.92
8.1.270.0060.00323.99
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0040.00422.06
8.1.230.0100.00317.48
8.1.220.0040.00418.77
8.1.210.0080.00019.00
8.1.200.0030.00617.10
8.1.190.0030.00617.41
8.1.180.0040.00418.10
8.1.170.0040.00418.66
8.1.160.0040.00418.92
8.1.150.0000.00818.66
8.1.140.0050.00317.43
8.1.130.0000.00817.73
8.1.120.0040.00417.46
8.1.110.0040.00417.38
8.1.100.0080.00017.55
8.1.90.0000.00717.47
8.1.80.0000.01017.54
8.1.70.0000.00717.42
8.1.60.0040.00417.63
8.1.50.0000.00717.56
8.1.40.0030.00617.61
8.1.30.0030.00517.59
8.1.20.0000.00817.60
8.1.10.0040.00417.63
8.1.00.0040.00417.52
8.0.300.0030.00619.98
8.0.290.0070.00017.17
8.0.280.0050.00318.50
8.0.270.0070.00017.34
8.0.260.0070.00016.76
8.0.250.0100.00017.06
8.0.240.0000.00916.89
8.0.230.0040.00417.09
8.0.220.0000.00717.01
8.0.210.0040.00416.92
8.0.200.0030.00317.05
8.0.190.0070.00017.05
8.0.180.0080.00017.02
8.0.170.0000.00717.02
8.0.160.0070.00016.98
8.0.150.0000.00716.89
8.0.140.0060.00616.96
8.0.130.0060.00013.45
8.0.120.0040.00416.99
8.0.110.0000.00716.82
8.0.100.0040.00416.93
8.0.90.0070.00016.95
8.0.80.0110.00717.01
8.0.70.0050.00316.78
8.0.60.0000.00716.85
8.0.50.0050.00316.86
8.0.30.0130.00817.25
8.0.20.0140.00917.40
8.0.10.0000.00817.06
8.0.00.0150.00516.66
7.4.330.0000.00516.85
7.4.320.0040.00416.62
7.4.300.0030.00316.53
7.4.290.0030.00316.63
7.4.280.0030.00316.48
7.4.270.0030.00316.44
7.4.260.0000.00513.33
7.4.250.0040.00416.42
7.4.240.0040.00316.56
7.4.230.0070.00016.54
7.4.220.0070.01016.55
7.4.210.0080.00816.65
7.4.200.0000.00716.44
7.4.190.0030.00316.73
7.4.160.0070.01016.46
7.4.150.0100.01317.40
7.4.140.0100.00617.86
7.4.130.0090.01016.58
7.4.120.0140.00316.66
7.4.110.0060.01016.49
7.4.100.0090.00816.81
7.4.90.0150.00316.59
7.4.80.0110.01119.39
7.4.70.0060.01116.54
7.4.60.0120.00616.47
7.4.50.0040.00416.61
7.4.40.0030.01022.77
7.4.30.0100.00716.69
7.4.00.0040.01415.15
7.3.330.0030.00313.25
7.3.320.0000.00513.49
7.3.310.0030.00316.50
7.3.300.0030.00316.46
7.3.290.0090.00616.41
7.3.280.0070.00916.47
7.3.270.0070.01317.40
7.3.260.0170.00018.24
7.3.250.0120.00516.55
7.3.240.0060.01016.58
7.3.230.0110.00716.50
7.3.210.0080.00816.45
7.3.200.0070.01619.39
7.3.190.0130.00316.69
7.3.180.0120.00916.44
7.3.170.0060.01016.34
7.3.160.0130.00616.54
7.3.120.0120.00514.98
7.3.110.0080.00814.97
7.3.100.0090.00715.00
7.3.90.0070.00815.07
7.3.80.0070.00715.03
7.3.70.0000.01214.98
7.3.60.0030.00714.70
7.3.50.0100.00614.84
7.3.40.0110.00514.97
7.3.30.0080.00614.88
7.3.20.0070.00916.54
7.3.10.0080.00616.71
7.3.00.0060.00616.59
7.2.330.0120.00616.65
7.2.320.0090.01216.65
7.2.310.0070.01016.71
7.2.300.0070.01016.92
7.2.290.0060.01016.80
7.2.250.0070.01014.98
7.2.240.0100.01015.13
7.2.230.0080.00515.15
7.2.220.0100.00614.95
7.2.210.0060.00614.98
7.2.200.0060.01014.91
7.2.190.0040.01014.68
7.2.180.0040.01215.02
7.2.170.0050.01015.02
7.2.160.0030.01215.00
7.2.150.0030.01217.06
7.2.140.0090.00417.00
7.2.130.0000.01316.96
7.2.120.0070.00717.05
7.2.110.0030.01316.95
7.2.100.0030.00717.07
7.2.90.0070.00716.99
7.2.80.0090.00016.92
7.2.70.0080.00417.05
7.2.60.0110.00417.04
7.2.50.0040.01216.93
7.2.40.0000.01316.87
7.2.30.0000.01317.10
7.2.20.0080.00817.07
7.2.10.0060.01017.06
7.2.00.0050.00718.17
7.1.330.0020.01515.79
7.1.320.0080.00615.92
7.1.310.0080.00515.68
7.1.300.0090.00515.87
7.1.290.0030.00915.74
7.1.280.0030.01315.82
7.1.270.0030.01215.92
7.1.260.0020.01315.50
7.1.250.0100.00315.85
7.1.240.0030.00915.57
7.1.230.0000.01316.05
7.1.220.0000.01515.82
7.1.210.0130.00015.91
7.1.200.0020.01115.62
7.1.190.0070.00715.84
7.1.180.0070.00715.80
7.1.170.0070.00315.94
7.1.160.0000.01115.82
7.1.150.0040.00915.87
7.1.140.0080.00815.84
7.1.130.0090.00615.71
7.1.120.0030.00515.76
7.1.110.0070.00715.71
7.1.100.0020.01417.02
7.1.90.0040.00715.82
7.1.80.0000.00915.55
7.1.70.0040.00916.49
7.1.60.0070.00717.57
7.1.50.0040.01416.31
7.1.40.0000.01115.89
7.1.30.0030.00615.71
7.1.20.0110.00415.98
7.1.10.0060.00915.53
7.1.00.0030.02118.97
7.0.330.0070.00715.57
7.0.320.0100.00315.53
7.0.310.0030.01015.41
7.0.300.0100.00715.43
7.0.290.0000.01015.44
7.0.280.0060.00615.55
7.0.270.0130.00015.16
7.0.260.0030.00615.41
7.0.250.0060.00615.57
7.0.240.0000.00815.52
7.0.230.0030.00815.60
7.0.220.0030.00515.13
7.0.210.0070.00715.47
7.0.200.0040.00516.16
7.0.190.0040.00715.55
7.0.180.0030.00915.44
7.0.170.0030.00915.45
7.0.160.0000.00815.61
7.0.150.0070.00715.60
7.0.140.0100.03518.82
7.0.130.0030.00915.33
7.0.120.0090.00615.53
7.0.110.0100.00615.18
7.0.100.0070.04517.70
7.0.90.0160.04017.70
7.0.80.0090.04217.72
7.0.70.0150.04317.60
7.0.60.0080.04317.74
7.0.50.0050.04517.96
7.0.40.0050.04716.74
7.0.30.0050.04416.82
7.0.20.0070.04816.84
7.0.10.0120.02716.75
7.0.00.0090.02716.82
5.6.400.0030.00914.23
5.6.390.0120.00314.29
5.6.380.0060.00614.05
5.6.370.0060.00614.70
5.6.360.0030.00914.42
5.6.350.0070.00314.61
5.6.340.0030.00914.48
5.6.330.0000.01414.28
5.6.320.0000.01414.00
5.6.310.0040.01114.50
5.6.300.0100.00314.59
5.6.290.0000.01414.12
5.6.280.0020.04317.79
5.6.270.0030.01014.25
5.6.260.0060.00714.63
5.6.250.0080.02517.55
5.6.240.0060.04017.59
5.6.230.0080.04317.42
5.6.220.0090.04117.49
5.6.210.0080.03617.45
5.6.200.0160.03017.71
5.6.190.0150.03117.63
5.6.180.0110.03717.73
5.6.170.0090.04017.70
5.6.160.0100.04117.78
5.6.150.0050.04417.66
5.6.140.0050.04817.63
5.6.130.0050.03617.64
5.6.120.0130.03817.65
5.6.110.0040.03917.64
5.6.100.0080.04917.66
5.6.90.0090.02517.71
5.6.80.0060.03817.33
5.6.70.0060.03517.32
5.6.60.0030.03417.19
5.6.50.0050.02717.38
5.6.40.0100.03517.21
5.6.30.0080.04017.43
5.6.20.0030.05017.26
5.6.10.0070.03917.26
5.6.00.0070.04417.26
5.5.380.0110.03617.39
5.5.370.0090.04117.37
5.5.360.0050.04117.27
5.5.350.0050.03917.34
5.5.340.0050.04517.45
5.5.330.0110.04017.35
5.5.320.0070.03017.66
5.5.310.0060.04617.41
5.5.300.0030.03017.56
5.5.290.0100.04017.39
5.5.280.0050.04917.69
5.5.270.0180.02217.56
5.5.260.0100.04017.56
5.5.250.0050.04417.46
5.5.240.0130.02117.09
5.5.230.0120.04017.30
5.5.220.0030.04717.22
5.5.210.0100.03717.26
5.5.200.0100.03417.07
5.5.190.0100.02817.27
5.5.180.0090.04217.12
5.5.170.0070.01014.39
5.5.160.0150.03517.26
5.5.150.0010.02817.35
5.5.140.0030.03017.08
5.5.130.0090.03717.33
5.5.120.0110.02117.25
5.5.110.0110.04017.14
5.5.100.0080.03817.17
5.5.90.0110.03217.02
5.5.80.0030.02317.25
5.5.70.0030.03717.13
5.5.60.0070.03017.16
5.5.50.0080.03117.19
5.5.40.0080.03317.03
5.5.30.0080.04116.98
5.5.20.0070.04317.09
5.5.10.0070.03717.04
5.5.00.0080.03817.18
5.4.450.0090.03015.71
5.4.440.0070.04315.64
5.4.430.0030.04315.50
5.4.420.0030.04615.68
5.4.410.0040.03715.54
5.4.400.0050.03615.53
5.4.390.0070.03015.43
5.4.380.0070.03515.53
5.4.370.0070.03815.39
5.4.360.0070.04315.44
5.4.350.0080.03815.48
5.4.340.0040.04315.48
5.4.330.0030.01011.83
5.4.320.0100.02315.34
5.4.310.0080.03315.48
5.4.300.0000.03815.37
5.4.290.0130.03315.44
5.4.280.0020.04515.45
5.4.270.0090.04015.35
5.4.260.0030.02715.52
5.4.250.0000.02815.49
5.4.240.0030.04415.53
5.4.230.0030.02615.43
5.4.220.0090.03915.43
5.4.210.0070.02415.52
5.4.200.0050.04315.36
5.4.190.0080.04015.43
5.4.180.0080.04115.35
5.4.170.0030.04415.50
5.4.160.0040.04215.33
5.4.150.0030.02715.47
5.4.140.0050.03814.12
5.4.130.0030.02214.14
5.4.120.0080.03514.03
5.4.110.0100.02214.20
5.4.100.0060.02314.16
5.4.90.0080.03514.20
5.4.80.0080.03314.07
5.4.70.0210.01314.15
5.4.60.0020.03114.07
5.4.50.0070.04014.09
5.4.40.0050.03014.16
5.4.30.0050.04014.04
5.4.20.0100.03714.15
5.4.10.0090.03914.15
5.4.00.0060.02813.85
5.3.290.0090.02513.32
5.3.280.0070.03513.19
5.3.270.0050.02213.29
5.3.260.0090.04113.22
5.3.250.0050.04113.20
5.3.240.0150.03213.22
5.3.230.0050.04413.21
5.3.220.0040.02713.19
5.3.210.0080.02013.23
5.3.200.0090.03813.18
5.3.190.0080.02313.26
5.3.180.0020.02613.23
5.3.170.0090.02913.25
5.3.160.0020.03313.19
5.3.150.0050.03213.19
5.3.140.0050.03513.23
5.3.130.0050.03213.14
5.3.120.0010.02613.21
5.3.110.0050.02713.26
5.3.100.0040.03312.96
5.3.90.0030.03212.92
5.3.80.0020.04012.93
5.3.70.0070.02212.96
5.3.60.0020.04412.91
5.3.50.0050.03412.95
5.3.40.0070.02712.83
5.3.30.0050.03112.90
5.3.20.0050.02012.82
5.3.10.0060.02812.71
5.3.00.0050.03512.73
5.2.170.0000.03311.29
5.2.160.0070.05011.01
5.2.150.0030.05311.29
5.2.140.0070.06011.08
5.2.130.0100.05311.04
5.2.120.0000.05011.14
5.2.110.0070.06311.20
5.2.100.0000.05011.02
5.2.90.0070.03011.06
5.2.80.0070.05311.17
5.2.70.0130.03011.21
5.2.60.0030.03011.16
5.2.50.0030.06011.13
5.2.40.0130.05010.89
5.2.30.0000.06010.97
5.2.20.0070.04011.10
5.2.10.0000.04310.89
5.2.00.0000.04010.66
5.1.60.0000.0539.99
5.1.50.0030.0279.88
5.1.40.0070.0279.99
5.1.30.0000.04310.36
5.1.20.0030.04010.26
5.1.10.0070.05310.06
5.1.00.0030.05310.07
5.0.50.0030.0408.85
5.0.40.0100.0378.85
5.0.30.0030.0508.85
5.0.20.0100.0378.85
5.0.10.0000.0378.85
5.0.00.0000.0408.85
4.4.90.0030.0238.85
4.4.80.0000.0308.85
4.4.70.0000.0308.85
4.4.60.0070.0338.85
4.4.50.0000.0408.85
4.4.40.0000.0608.85
4.4.30.0000.0208.85
4.4.20.0030.0208.85
4.4.10.0000.0378.85
4.4.00.0030.0538.85
4.3.110.0030.0338.85
4.3.100.0000.0378.85
4.3.90.0030.0338.85
4.3.80.0100.0508.85
4.3.70.0070.0308.85
4.3.60.0030.0338.85
4.3.50.0000.0308.85
4.3.40.0030.0238.85
4.3.30.0000.0308.85
4.3.20.0030.0278.85
4.3.10.0030.0238.85
4.3.00.0000.0178.85

preferences:
53.41 ms | 401 KiB | 5 Q