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($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.0060.01318.40
8.3.50.0150.00316.58
8.3.40.0110.00718.92
8.3.30.0070.00718.78
8.3.20.0040.00418.77
8.3.10.0030.00620.65
8.3.00.0080.00017.50
8.2.180.0110.00716.63
8.2.170.0090.00622.96
8.2.160.0050.00822.17
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00419.95
8.2.110.0090.00020.54
8.2.100.0060.00617.78
8.2.90.0000.00917.88
8.2.80.0000.00918.73
8.2.70.0030.00517.38
8.2.60.0040.00417.63
8.2.50.0000.00817.60
8.2.40.0000.00817.75
8.2.30.0000.00717.72
8.2.20.0050.00317.66
8.2.10.0050.00317.79
8.2.00.0060.00317.83
8.1.280.0040.01125.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0060.00322.02
8.1.230.0060.00617.71
8.1.220.0050.00317.79
8.1.210.0060.00318.77
8.1.200.0030.00617.48
8.1.190.0040.00417.35
8.1.180.0040.00418.10
8.1.170.0000.00817.75
8.1.160.0000.00818.86
8.1.150.0040.00418.67
8.1.140.0000.00717.39
8.1.130.0000.00717.90
8.1.120.0030.00517.37
8.1.110.0080.00217.41
8.1.100.0000.00717.50
8.1.90.0070.00017.56
8.1.80.0000.00717.37
8.1.70.0000.00817.38
8.1.60.0050.00217.59
8.1.50.0000.00817.54
8.1.40.0040.00417.59
8.1.30.0070.00017.73
8.1.20.0040.00417.71
8.1.10.0000.00817.63
8.1.00.0040.00417.42
8.0.300.0030.00618.77
8.0.290.0040.00416.75
8.0.280.0000.00718.09
8.0.270.0030.00318.10
8.0.260.0030.00318.61
8.0.250.0030.00517.10
8.0.240.0050.00616.93
8.0.230.0030.00317.02
8.0.220.0070.00016.88
8.0.210.0070.00016.89
8.0.200.0070.00317.11
8.0.190.0030.00517.04
8.0.180.0040.00416.96
8.0.170.0060.00317.00
8.0.160.0070.00016.95
8.0.150.0050.00316.93
8.0.140.0050.00516.96
8.0.130.0000.00513.39
8.0.120.0040.00416.99
8.0.110.0030.00516.78
8.0.100.0020.00517.02
8.0.90.0050.00316.97
8.0.80.0060.01217.04
8.0.70.0000.00717.00
8.0.60.0020.00516.79
8.0.50.0040.00417.03
8.0.30.0110.00817.01
8.0.20.0120.00617.20
8.0.10.0040.00417.00
8.0.00.0120.00616.75
7.4.330.0020.00214.68
7.4.320.0040.00416.54
7.4.300.0030.00316.66
7.4.290.0000.00716.68
7.4.280.0060.00316.68
7.4.270.0070.00416.59
7.4.260.0050.00013.34
7.4.250.0000.00716.39
7.4.240.0000.00716.67
7.4.230.0060.00316.67
7.4.220.0060.00916.51
7.4.210.0060.00916.56
7.4.200.0030.00316.63
7.4.190.0050.00216.79
7.4.160.0170.00016.38
7.4.150.0100.01317.07
7.4.140.0150.00617.22
7.4.130.0070.01216.63
7.4.120.0080.00916.54
7.4.110.0140.00716.66
7.4.100.0090.00916.59
7.4.90.0090.00916.47
7.4.80.0040.01318.80
7.4.70.0060.01516.50
7.4.60.0100.01016.71
7.4.50.0050.00016.43
7.4.40.0060.01022.27
7.4.30.0100.00716.50
7.4.10.0140.00415.11
7.4.00.0090.00615.17
7.3.330.0060.00013.45
7.3.320.0030.00313.39
7.3.310.0040.00416.58
7.3.300.0040.00416.41
7.3.290.0070.01016.41
7.3.280.0120.00916.43
7.3.270.0090.00917.07
7.3.260.0140.00718.24
7.3.250.0110.00916.50
7.3.240.0110.00516.79
7.3.230.0070.01016.63
7.3.210.0130.00316.55
7.3.200.0110.00619.39
7.3.190.0030.01716.74
7.3.180.0120.00616.53
7.3.170.0060.01016.56
7.3.160.0160.00016.58
7.3.130.0060.00915.11
7.3.120.0080.00715.01
7.3.110.0120.00615.11
7.3.100.0000.01415.11
7.3.90.0090.00215.11
7.3.80.0030.00615.11
7.3.70.0060.00615.11
7.3.60.0000.01615.11
7.3.50.0040.00415.11
7.3.40.0000.00815.11
7.3.30.0110.00415.11
7.3.20.0070.00316.48
7.3.10.0070.00716.58
7.3.00.0000.01516.41
7.2.330.0090.01316.59
7.2.320.0130.01016.51
7.2.310.0050.01516.59
7.2.300.0090.00916.73
7.2.290.0090.00916.77
7.2.260.0030.01615.11
7.2.250.0040.01515.11
7.2.240.0070.01015.11
7.2.230.0000.00915.11
7.2.220.0000.01715.18
7.2.210.0080.00415.15
7.2.200.0090.00315.11
7.2.190.0030.01215.11
7.2.180.0070.00715.11
7.2.170.0040.00715.11
7.2.160.0000.00915.14
7.2.150.0040.00917.02
7.2.140.0000.01016.92
7.2.130.0070.01116.95
7.2.120.0170.00016.92
7.2.110.0070.00716.72
7.2.100.0000.01416.88
7.2.90.0070.01016.88
7.2.80.0000.01316.97
7.2.70.0030.01316.96
7.2.60.0070.01016.87
7.2.50.0100.01016.75
7.2.40.0070.01017.03
7.2.30.0100.00716.94
7.2.20.0100.00716.75
7.2.10.0060.00917.01
7.2.00.0060.00917.97
7.1.330.0040.00815.79
7.1.320.0060.00315.52
7.1.310.0000.01315.76
7.1.300.0070.00315.76
7.1.290.0040.00815.60
7.1.280.0070.00715.87
7.1.270.0080.00015.70
7.1.260.0030.00615.95
7.1.250.0000.01515.83
7.1.240.0000.01015.91
7.1.230.0060.00615.80
7.1.220.0030.01315.39
7.1.210.0070.00715.68
7.1.200.0020.00915.81
7.1.190.0100.00715.63
7.1.180.0080.00815.73
7.1.170.0160.00315.80
7.1.160.0090.00315.79
7.1.150.0000.01215.91
7.1.140.0030.01015.91
7.1.130.0030.00615.84
7.1.120.0060.00316.00
7.1.110.0140.00415.85
7.1.100.0070.00716.86
7.1.90.0120.00315.57
7.1.80.0030.00715.75
7.1.70.0050.00616.36
7.1.60.0070.00716.54
7.1.50.0090.00216.41
7.1.40.0050.00816.24
7.1.30.0030.01116.13
7.1.20.0120.00416.24
7.1.10.0040.00716.13
7.1.00.0040.00616.27
7.0.330.0090.00615.29
7.0.320.0090.00615.32
7.0.310.0090.00315.34
7.0.300.0090.00915.38
7.0.290.0030.00815.18
7.0.280.0060.01015.23
7.0.270.0030.01015.13
7.0.260.0030.01415.45
7.0.250.0070.00715.11
7.0.240.0060.01015.18
7.0.230.0040.00715.18
7.0.220.0080.00815.55
7.0.210.0100.00315.49
7.0.200.0050.00516.25
7.0.190.0020.01016.09
7.0.180.0030.00715.81
7.0.170.0040.00915.93
7.0.160.0040.00715.93
7.0.150.0030.00915.91
7.0.140.0030.00615.91
7.0.130.0050.00516.02
7.0.120.0060.00516.08
7.0.110.0060.00315.99
7.0.100.0030.00516.08
7.0.90.0030.00616.03
7.0.80.0040.00615.81
7.0.70.0030.00816.03
7.0.60.0030.00715.96
7.0.50.0050.00415.82
7.0.40.0050.00815.78
7.0.30.0030.00815.78
7.0.20.0080.00515.78
7.0.10.0070.00515.78
7.0.00.0070.00515.78
5.6.400.0040.00815.11
5.6.390.0120.00315.11
5.6.380.0110.00815.11
5.6.370.0030.00915.11
5.6.360.0060.01215.11
5.6.350.0070.01015.11
5.6.340.0000.00915.11
5.6.330.0090.00315.11
5.6.320.0000.00915.11
5.6.310.0060.00915.11
5.6.300.0060.02318.04
5.6.290.0040.03017.97
5.6.280.0040.03817.99
5.6.270.0090.02618.01
5.6.260.0020.02918.01
5.6.250.0100.01917.96
5.6.240.0070.02517.98
5.6.230.0050.02717.97
5.6.220.0080.02218.03
5.6.210.0040.02717.98
5.6.200.0040.02718.02
5.6.190.0100.02318.02
5.6.180.0100.02118.03
5.6.170.0070.02718.02
5.6.160.0020.02818.03
5.6.150.0030.03917.97
5.6.140.0050.03017.92
5.6.130.0080.02217.97
5.6.120.0060.03118.02
5.6.110.0100.02617.94
5.6.100.0060.03018.06
5.6.90.0090.02418.04
5.6.80.0080.02517.71
5.6.70.0080.02317.74
5.6.60.0080.02617.67
5.6.50.0080.02417.72
5.6.40.0070.02517.76
5.6.30.0020.03117.67
5.6.20.0120.03717.74
5.6.10.0070.04317.65
5.6.00.0060.02717.74
5.5.380.0050.02616.38
5.5.370.0030.02716.29
5.5.360.0080.02016.37
5.5.350.0060.02416.38
5.5.340.0080.02716.57
5.5.330.0030.03116.48
5.5.320.0050.02416.57
5.5.310.0110.02916.40
5.5.300.0030.02916.62
5.5.290.0070.02516.55
5.5.280.0050.02816.59
5.5.270.0130.02416.61
5.5.260.0050.03216.61
5.5.250.0040.04616.47
5.5.240.0030.02516.33
5.5.230.0060.02416.29
5.5.220.0020.04216.11
5.5.210.0070.05116.17
5.5.200.0020.02616.16
5.5.190.0030.02716.11
5.5.180.0030.04416.24
5.5.170.0140.00015.11
5.5.160.0030.02416.27
5.5.150.0060.02216.26
5.5.140.0030.02616.16
5.5.130.0020.02916.21
5.5.120.0100.01816.16
5.5.110.0050.02316.25
5.5.100.0060.02416.24
5.5.90.0050.03416.19
5.5.80.0070.02316.03
5.5.70.0070.03516.19
5.5.60.0030.02716.19
5.5.50.0060.02016.20
5.5.40.0030.02316.24
5.5.30.0020.04416.23
5.5.20.0050.02516.21
5.5.10.0050.02216.21
5.5.00.0020.02416.10
5.4.450.0050.02417.32
5.4.440.0020.02817.19
5.4.430.0070.02217.33
5.4.420.0030.02417.18
5.4.410.0060.02817.10
5.4.400.0050.02217.03
5.4.390.0120.01917.05
5.4.380.0050.02517.14
5.4.370.0060.02117.02
5.4.360.0050.02817.16
5.4.350.0000.02917.04
5.4.340.0050.03717.08
5.4.330.0030.00715.11
5.4.320.0060.03617.03
5.4.310.0060.04517.09
5.4.300.0040.03217.05
5.4.290.0030.02317.12
5.4.280.0070.02417.00
5.4.270.0050.02317.02
5.4.260.0070.03717.12
5.4.250.0040.02117.04
5.4.240.0020.03617.09
5.4.230.0070.02317.04
5.4.220.0030.02317.00
5.4.210.0030.02617.13
5.4.200.0020.03117.06
5.4.190.0110.02317.08
5.4.180.0060.02017.15
5.4.170.0020.02517.01
5.4.160.0050.02017.09
5.4.150.0050.02217.08
5.4.140.0060.02115.95
5.4.130.0050.02115.96
5.4.120.0060.01915.80
5.4.110.0030.03315.83
5.4.100.0000.03215.90
5.4.90.0030.02215.93
5.4.80.0020.03115.82
5.4.70.0030.02315.89
5.4.60.0030.02315.79
5.4.50.0120.01515.89
5.4.40.0020.03115.91
5.4.30.0040.02115.91
5.4.20.0040.02115.78
5.4.10.0070.01915.89
5.4.00.0050.02715.78
5.3.290.0100.03715.78
5.3.280.0030.02315.78
5.3.270.0040.02415.78
5.3.260.0050.02015.78
5.3.250.0000.02515.78
5.3.240.0050.02215.78
5.3.230.0080.01915.78
5.3.220.0060.02015.78
5.3.210.0040.02215.78
5.3.200.0030.02915.78
5.3.190.0020.03115.78
5.3.180.0000.03315.78
5.3.170.0140.02115.78
5.3.160.0030.02315.78
5.3.150.0030.02615.78
5.3.140.0050.02115.78
5.3.130.0080.02115.78
5.3.120.0030.02515.78
5.3.110.0050.02815.78
5.3.100.0040.02115.78
5.3.90.0030.02215.78
5.3.80.0080.03815.78
5.3.70.0000.02715.78
5.3.60.0050.02115.78
5.3.50.0030.02115.78
5.3.40.0020.02815.78
5.3.30.0050.01715.78
5.3.20.0020.02215.78
5.3.10.0040.02015.78
5.3.00.0040.02015.78
5.2.170.0030.03116.45
5.2.160.0000.03016.45
5.2.150.0000.03216.45
5.2.140.0000.03816.45
5.2.130.0040.02616.45
5.2.120.0030.02716.45
5.2.110.0030.04516.45
5.2.100.0070.05616.45
5.2.90.0030.03316.45
5.2.80.0030.03716.45
5.2.70.0030.04416.45
5.2.60.0030.02716.45
5.2.50.0000.03316.45
5.2.40.0000.03116.45
5.2.30.0070.03516.45
5.2.20.0030.02916.45
5.2.10.0000.03516.45
5.2.00.0030.02816.45
5.1.60.0030.02516.45
5.1.50.0000.02616.45
5.1.40.0030.03716.45
5.1.30.0000.03016.45
5.1.20.0000.03516.45
5.1.10.0000.03716.45
5.1.00.0000.03116.45
5.0.50.0030.02116.45
5.0.40.0030.01816.45
5.0.30.0070.03716.45
5.0.20.0030.01816.45
5.0.10.0180.00716.45
5.0.00.0000.03516.45
4.4.90.0000.01716.45
4.4.80.0000.01816.45
4.4.70.0000.01716.45
4.4.60.0000.01616.45
4.4.50.0000.01616.45
4.4.40.0070.02816.45
4.4.30.0000.01816.45
4.4.20.0030.03316.45
4.4.10.0000.01716.45
4.4.00.0000.02516.45
4.3.110.0030.01516.45
4.3.100.0070.02316.45
4.3.90.0030.01516.45
4.3.80.0000.02516.45
4.3.70.0060.01216.45
4.3.60.0060.01316.45
4.3.50.0000.01716.45
4.3.40.0000.02816.45
4.3.30.0030.01616.45
4.3.20.0000.01716.45
4.3.10.0000.01816.45
4.3.00.0000.02216.45

preferences:
45.07 ms | 401 KiB | 5 Q