3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertRGBToXY($red, $green, $blue) { // Normalize the values to 1 $normalizedToOne['red'] = $red / 255; $normalizedToOne['green'] = $green / 255; $normalizedToOne['blue'] = $blue / 255; // Make colors more vivid foreach ($normalizedToOne as $key => $normalized) { if ($normalized > 0.04045) { $color[$key] = pow(($normalized + 0.055) / (1.0 + 0.055), 2.4); } else { $color[$key] = $normalized / 12.92; } } // Convert to XYZ using the Wide RGB D65 formula $xyz['x'] = $color['red'] * 0.664511 + $color['green'] * 0.154324 + $color['blue'] * 0.162028; $xyz['y'] = $color['red'] * 0.283881 + $color['green'] * 0.668433 + $color['blue'] * 0.047685; $xyz['z'] = $color['red'] * 0.000000 + $color['green'] * 0.072310 + $color['blue'] * 0.986039; // Calculate the x/y values if (array_sum($xyz) == 0) { $x = 0; $y = 0; } else { $x = $xyz['x'] / array_sum($xyz); $y = $xyz['y'] / array_sum($xyz); } return array( 'x' => $x, 'y' => $y, 'bri' => round($xyz['y'] * 255) ); } function convertXYToRGB($x, $y, $bri = 255) { // Calculate XYZ $z = 1.0 - $x - $y; $xyz['y'] = $bri / 255; $xyz['x'] = ($xyz['y'] / $y) * $x; $xyz['z'] = ($xyz['y'] / $y) * $z; // Convert to RGB using Wide RGB D65 conversion $color['red'] = $xyz['x'] * 1.656492 - $xyz['y'] * 0.354851 - $xyz['z'] * 0.255038; $color['green'] = -$xyz['x'] * 0.707196 + $xyz['y'] * 1.655397 + $xyz['z'] * 0.036152; $color['blue'] = $xyz['x'] * 0.051713 - $xyz['y'] * 0.121364 + $xyz['z'] * 1.011530; foreach ($color as $key => $normalized) { // Apply reverse gamma correction if ($normalized <= 0.0031308) { $color[$key] = 12.92 * $normalized; } else { $color[$key] = (1.0 + 0.055) * pow($normalized, 1.0 / 2.4) - 0.055; } // Scale back from a maximum of 1 to a maximum of 255 $color[$key] = round($color[$key] * 255); } return $color; } print_r($rgb = convertRGBToXY(0, 0, 255)); print_r(convertXYToRGB($rgb['x'], $rgb['y'], 255));

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.130.0100.00718.83
8.3.120.0090.00020.88
8.3.110.0030.00620.94
8.3.100.0030.00624.06
8.3.90.0100.01026.77
8.3.80.0090.00318.68
8.3.70.0060.01217.00
8.3.60.0110.01118.43
8.3.50.0110.00818.42
8.3.40.0000.01519.09
8.3.30.0110.00419.17
8.3.20.0080.00019.40
8.3.10.0040.00421.20
8.3.00.0040.00423.48
8.2.250.0100.01018.39
8.2.240.0070.01119.33
8.2.230.0030.01322.58
8.2.220.0000.01137.54
8.2.210.0030.01326.77
8.2.200.0070.00416.88
8.2.190.0070.01416.75
8.2.180.0090.00918.41
8.2.170.0170.00322.96
8.2.160.0150.00619.32
8.2.150.0090.00024.18
8.2.140.0050.00224.66
8.2.130.0000.00821.44
8.2.120.0070.00026.35
8.2.110.0030.00719.39
8.2.100.0060.00618.16
8.2.90.0030.00519.21
8.2.80.0000.00817.97
8.2.70.0030.00518.30
8.2.60.0050.00318.29
8.2.50.0050.00518.10
8.2.40.0040.00419.55
8.2.30.0040.00419.70
8.2.20.0000.00718.27
8.2.10.0000.00818.27
8.2.00.0040.00419.71
8.1.300.0130.00316.63
8.1.290.0030.00630.84
8.1.280.0040.01125.92
8.1.270.0040.00422.40
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0070.00321.30
8.1.230.0070.00422.33
8.1.220.0030.00617.79
8.1.210.0030.00518.77
8.1.200.0060.00317.50
8.1.190.0030.00617.60
8.1.180.0070.00318.10
8.1.170.0030.00618.80
8.1.160.0040.00419.20
8.1.150.0040.00419.07
8.1.140.0070.00017.95
8.1.130.0070.00017.75
8.1.120.0030.00517.66
8.1.110.0070.00017.62
8.1.100.0000.00717.71
8.1.90.0030.00617.59
8.1.80.0040.00417.65
8.1.70.0030.00317.63
8.1.60.0080.00017.78
8.1.50.0040.00417.86
8.1.40.0050.00317.82
8.1.30.0040.00417.89
8.1.20.0080.00017.82
8.1.10.0050.00317.88
8.1.00.0000.00917.79
8.0.300.0040.00418.77
8.0.290.0060.00616.73
8.0.280.0000.00718.57
8.0.270.0000.00717.53
8.0.260.0070.00016.96
8.0.250.0100.00017.24
8.0.240.0000.00817.19
8.0.230.0060.00317.21
8.0.220.0000.00717.07
8.0.210.0040.00417.14
8.0.200.0070.00017.21
8.0.190.0040.00417.25
8.0.180.0050.00317.19
8.0.170.0070.00317.12
8.0.160.0030.00517.01
8.0.150.0040.00417.20
8.0.140.0040.00417.05
8.0.130.0030.00313.58
8.0.120.0050.00217.09
8.0.110.0080.00017.16
8.0.100.0020.00517.00
8.0.90.0030.00517.15
8.0.80.0090.01317.15
8.0.70.0030.00517.23
8.0.60.0060.00317.07
8.0.50.0070.00017.21
8.0.30.0090.00817.28
8.0.20.0090.01017.47
8.0.10.0040.00417.19
8.0.00.0100.00917.00
7.4.330.0000.00515.55
7.4.320.0000.00716.80
7.4.300.0030.00316.76
7.4.290.0040.00416.71
7.4.280.0080.00016.86
7.4.270.0000.00816.80
7.4.260.0080.00016.79
7.4.250.0030.00516.82
7.4.240.0000.00716.86
7.4.230.0040.00316.71
7.4.220.0050.00516.94
7.4.210.0110.00616.78
7.4.200.0000.00716.94
7.4.160.0090.00716.85
7.4.140.0130.00817.86
7.4.130.0090.00916.78
7.4.120.0100.00916.77
7.4.110.0100.01016.68
7.4.100.0090.00916.67
7.4.90.0200.00016.87
7.4.80.0110.01119.39
7.4.70.0100.00716.73
7.4.60.0090.00616.68
7.4.50.0090.00616.53
7.4.40.0060.01216.76
7.4.00.0090.00715.06
7.3.330.0030.00313.50
7.3.320.0030.00313.52
7.3.310.0030.00316.55
7.3.300.0000.00816.67
7.3.290.0050.00216.67
7.3.280.0070.01116.58
7.3.260.0140.00416.69
7.3.240.0090.00916.70
7.3.230.0110.00916.79
7.3.210.0110.00716.86
7.3.200.0140.00316.50
7.3.190.0130.01016.92
7.3.180.0080.00816.59
7.3.170.0070.01416.87
7.3.160.0060.00916.71
7.3.120.0070.01414.99
7.3.110.0070.01114.88
7.3.100.0150.00314.86
7.3.90.0030.01015.20
7.3.80.0030.00815.33
7.3.70.0120.00315.26
7.3.60.0040.00915.20
7.3.50.0090.00614.99
7.3.40.0040.01215.07
7.3.30.0110.00414.97
7.3.20.0070.00417.07
7.3.10.0150.00016.97
7.3.00.0110.00017.04
7.2.330.0090.00916.98
7.2.320.0140.00417.14
7.2.310.0030.01416.79
7.2.300.0160.00416.94
7.2.290.0130.00917.16
7.2.250.0100.00615.18
7.2.240.0100.01015.32
7.2.230.0060.00915.45
7.2.220.0060.00915.38
7.2.210.0100.00315.05
7.2.200.0140.00314.92
7.2.190.0100.00615.43
7.2.180.0070.00415.15
7.2.170.0090.00915.10
7.2.70.0120.01815.27
7.2.60.0230.00314.89
7.2.50.0310.00715.45
7.2.40.0170.01415.29
7.2.30.0250.01615.11
7.2.20.0370.00615.39
7.2.10.0210.01015.23
7.2.00.0240.00915.18
7.1.330.0030.01316.14
7.1.320.0000.01516.05
7.1.310.0110.00416.13
7.1.300.0000.01016.23
7.1.290.0030.00716.11
7.1.280.0000.00915.87
7.1.270.0060.00315.56
7.1.260.0100.00316.12
7.1.200.0040.00416.07
7.1.170.0120.01613.96
7.1.160.0200.00513.87
7.1.150.0230.00314.03
7.1.140.1200.00614.23
7.1.130.0330.00313.94
7.1.120.0290.01214.19
7.1.110.0340.00914.37
7.1.100.0270.00514.11
7.1.90.0170.00814.28
7.1.80.0160.01014.05
7.1.70.0340.00713.95
7.1.60.0450.00932.42
7.1.50.0450.01332.00
7.1.40.0450.01632.11
7.1.30.0460.01532.12
7.1.20.0420.01331.89
7.1.10.0190.01313.85
7.1.00.0280.00013.93

preferences:
28.75 ms | 403 KiB | 5 Q