3v4l.org

run code in 300+ PHP versions simultaneously
<?php function reduce($bits, $value = '0') { if (strlen($bits) == 1) { // a single bit can be flipped as needed return ($bits[0] == $value) ? 0 : 1; } if ($bits[0] == $value) { // nothing to do with this bit, flip the remainder return reduce(substr($bits, 1)); } // need to convert balance of string to 1 followed by 0's // then we can flip this bit, and then reduce the new string to 0 return reduce(substr($bits, 1), '1') + 1 + reduce(str_pad('1', strlen($bits) - 1, '0')); } for ($i = 0; $i < 128; $i++) { echo "$i (" . decbin($i) . ") takes " . reduce(decbin($i)) . " steps\n"; }

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.110.0030.00720.94
8.3.100.0070.00324.06
8.3.90.0030.00626.77
8.3.80.0070.00318.56
8.3.70.0120.00416.75
8.3.60.0060.00918.18
8.3.50.0150.00524.44
8.3.40.0100.01618.63
8.3.30.0120.00820.83
8.3.20.0090.00722.82
8.3.10.0090.00722.88
8.3.00.0050.01123.29
8.2.230.0090.00022.58
8.2.220.0090.00037.54
8.2.210.0100.01026.77
8.2.200.0030.00616.63
8.2.190.0070.01016.58
8.2.180.0070.01718.50
8.2.170.0000.01522.96
8.2.160.0090.00822.54
8.2.150.0020.01323.57
8.2.140.0050.00923.81
8.2.130.0080.00524.56
8.2.120.0120.00321.38
8.2.110.0130.00322.61
8.2.100.0090.00820.37
8.2.90.0070.01020.28
8.2.80.0050.00720.89
8.2.70.0070.00620.23
8.2.60.0080.00520.51
8.2.50.0040.00820.51
8.2.40.0090.00520.65
8.2.30.0060.00721.21
8.2.20.0060.00720.52
8.2.10.0080.00721.05
8.2.00.0030.00921.10
8.1.290.0060.00618.88
8.1.280.0130.00325.92
8.1.270.0090.00521.77
8.1.260.0060.00824.66
8.1.250.0090.00525.97
8.1.240.0080.00523.38
8.1.230.0070.00720.46
8.1.220.0090.00520.35
8.1.210.0090.00720.87
8.1.200.0030.01120.10
8.1.190.0110.00320.10
8.1.180.0080.00620.53
8.1.170.0050.01020.29
8.1.160.0060.01120.94
8.1.150.0070.00620.93
8.1.140.0050.01020.93
8.1.130.0060.00821.55
8.1.120.0070.00520.21
8.1.110.0040.00720.16
8.1.100.0080.00520.17
8.1.90.0030.01020.13
8.1.80.0090.00520.18
8.1.70.0080.00420.20
8.1.60.0090.00320.27
8.1.50.0060.00620.21
8.1.40.0050.00720.20
8.1.30.0060.00620.35
8.1.20.0080.00420.26
8.1.10.0080.00520.21
8.1.00.0090.00520.23
8.0.300.0080.00520.87
8.0.290.0120.00519.79
8.0.280.0190.00420.71
8.0.270.0120.00520.45
8.0.260.0130.00820.67
8.0.250.0140.00619.96
8.0.240.0150.00919.97
8.0.230.0090.00719.98
8.0.220.0140.00419.92
8.0.210.0130.00619.88
8.0.200.0160.00119.96
8.0.190.0130.00419.96
8.0.180.0080.00919.93
8.0.170.0130.00619.88
8.0.160.0140.00119.94
8.0.150.0120.00919.88
8.0.140.0130.00519.86
8.0.130.0080.00818.17
8.0.120.0140.00419.91
8.0.110.0100.00919.94
8.0.100.0130.00419.95
8.0.90.0180.00319.95
8.0.80.0120.01118.95
8.0.70.0060.00819.93
8.0.60.0120.00919.98
8.0.50.0140.00319.90
8.0.30.0140.00919.01
8.0.20.0120.01319.05
8.0.10.0210.00819.98
8.0.00.0120.01018.98
7.4.330.0080.00719.26
7.4.320.0060.00719.74
7.4.300.0110.00919.79
7.4.290.0140.00619.69
7.4.280.0140.00519.76
7.4.270.0130.00619.69
7.4.260.0140.00518.13
7.4.250.0180.00819.76
7.4.240.0100.00718.74
7.4.230.0200.00619.69
7.4.220.0120.00718.63
7.4.210.0180.00818.18
7.4.200.0170.00819.75
7.4.190.0210.00922.96
7.4.180.0170.01422.96
7.4.160.0240.00519.78
7.4.150.0180.01219.72
7.4.140.0230.00519.79
7.4.130.0160.01118.08
7.4.120.0170.00618.74
7.4.110.0200.00718.65
7.4.100.0160.01018.74
7.4.90.0120.01218.19
7.4.80.0110.01118.82
7.4.70.0150.01018.09
7.4.60.0180.00717.54
7.4.50.0150.00917.55
7.4.40.0120.00917.56
7.4.30.0100.01117.64
7.4.20.0120.01017.52
7.4.10.0150.00817.56
7.4.00.0110.01217.56
7.3.330.0160.00519.59
7.3.320.0170.00718.16
7.3.310.0170.00219.61
7.3.300.0160.00519.61
7.3.290.0110.01118.04
7.3.280.0170.00919.68
7.3.270.0200.00919.66
7.3.260.0170.01118.65
7.3.250.0140.01119.65
7.3.240.0120.00917.49
7.3.230.0110.01318.67
7.3.220.0110.01519.63
7.3.210.0120.01118.05
7.3.200.0110.01218.09
7.3.190.0130.01118.08
7.3.180.0140.00817.44
7.3.170.0110.01217.50
7.3.160.0120.00917.45
7.3.150.0110.01117.52
7.3.140.0140.00917.50
7.3.130.0120.01017.53
7.3.120.0110.01017.51
7.3.110.0120.00817.41
7.3.100.0130.01217.50
7.3.90.0140.00917.58
7.3.80.0120.01217.50
7.3.70.0120.00917.56
7.3.60.0150.00817.53
7.3.50.0130.01017.46
7.3.40.0120.01117.47
7.3.30.0120.01017.50
7.3.20.0150.00917.51
7.3.10.0110.01317.45
7.3.00.0120.00917.49
7.2.340.0170.00819.71
7.2.330.0180.00818.30
7.2.320.0150.01418.19
7.2.310.0130.01218.01
7.2.300.0150.01117.86
7.2.290.0140.01117.68
7.2.280.0170.00917.68
7.2.270.0150.01217.79
7.2.260.0160.00717.68
7.2.250.0130.01117.75
7.2.240.0130.01317.65
7.2.230.0190.00817.70
7.2.220.0150.01217.68
7.2.210.0110.01517.65
7.2.200.0200.01317.71
7.2.190.0150.01017.71
7.2.180.0160.00917.63
7.2.170.0150.01117.70
7.2.160.0160.00817.67
7.2.150.0150.01117.76
7.2.140.0220.01117.73
7.2.130.0130.01217.79
7.2.120.0160.00817.75
7.2.110.0150.00917.81
7.2.100.0270.01117.77
7.2.90.0120.01317.73
7.2.80.0160.01117.67
7.2.70.0150.01117.73
7.2.60.0140.01117.65
7.2.50.0240.00817.78
7.2.40.0160.01017.72
7.2.30.0120.01217.80
7.2.20.0130.01217.74
7.2.10.0130.01117.81
7.2.00.0100.01317.74

preferences:
32.89 ms | 403 KiB | 5 Q