3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @file A fizzbuzz reference implementation. * @author Brad Czerniak (ao5357@gmail.com) */ /** * Outputs fizzes and buzzes over a loop. * * @param int $iterations * The number of times to iterate over the loop * @param int $offset * The number to start at * @param string $fizz * The string to output for the first modulo condition, typically 'fizz'. * @param string $buzz * The string to output for the second modulo condition, typically 'buzz'. * @param string $fizzbuzz * The string to output for the third (usually combined) modulo condition, typically 'fizzbuzz'. * @param int $fizz_int * The first modulus * @param int $buzz_int * The second modulus * @param int $fizzbuzz_int * The third (usually combined) modulus * * @return An array of the loop's output */ function fizzbuzz($iterations = 100, $offset = 1, $fizz = 'fizz', $buzz = 'buzz', $fizzbuzz = 'fizzbuzz', $fizz_int = 3, $buzz_int = 5, $fizzbuzz_int = 15) { $i = $offset; $ret = array(); while($i < ($offset + $iterations)){ if($i % $fizzbuzz_int == 0){ $ret[] = $fizzbuzz;} elseif($i % $buzz_int == 0){ $ret[] = $buzz;} elseif($i % $fizz_int == 0){ $ret[] = $fizz;} else{ $ret[] = $i;} $i++; } } print_r(fizzbuzz());

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.0070.01318.30
8.3.50.0110.01121.14
8.3.40.0120.00318.71
8.3.30.0070.00718.71
8.3.20.0050.00318.73
8.3.10.0090.00020.30
8.3.00.0070.00317.63
8.2.180.0090.00616.50
8.2.170.0040.01122.96
8.2.160.0070.00722.25
8.2.150.0030.00624.18
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0040.00419.83
8.2.110.0100.00021.03
8.2.100.0080.00417.84
8.2.90.0050.00319.36
8.2.80.0000.00818.05
8.2.70.0060.00317.75
8.2.60.0050.00317.93
8.2.50.0030.00518.07
8.2.40.0050.00218.16
8.2.30.0070.00019.90
8.2.20.0040.00417.80
8.2.10.0040.00417.64
8.2.00.0060.00317.80
8.1.280.0070.01025.92
8.1.270.0050.00323.99
8.1.260.0050.00326.35
8.1.250.0050.00328.09
8.1.240.0100.00022.42
8.1.230.0070.00420.90
8.1.220.0000.00818.77
8.1.210.0060.00318.93
8.1.200.0060.00317.35
8.1.190.0000.00717.63
8.1.180.0040.00418.10
8.1.170.0040.00418.89
8.1.160.0040.00418.91
8.1.150.0070.00018.71
8.1.140.0070.00017.51
8.1.130.0000.00717.83
8.1.120.0030.00317.49
8.1.110.0000.00717.50
8.1.100.0030.00517.40
8.1.90.0040.00417.53
8.1.80.0000.00717.38
8.1.70.0030.00317.33
8.1.60.0040.00417.48
8.1.50.0070.00017.41
8.1.40.0040.00417.44
8.1.30.0000.00817.50
8.1.20.0040.00417.66
8.1.10.0050.00217.53
8.1.00.0050.00217.44
8.0.300.0070.00019.98
8.0.290.0070.00716.58
8.0.280.0000.00718.46
8.0.270.0030.00317.29
8.0.260.0040.00416.90
8.0.250.0000.00716.86
8.0.240.0080.00016.96
8.0.230.0030.00316.87
8.0.220.0030.00616.88
8.0.210.0000.00716.82
8.0.200.0030.00316.94
8.0.190.0030.00516.88
8.0.180.0040.00416.92
8.0.170.0030.00716.85
8.0.160.0050.00316.82
8.0.150.0000.00816.78
8.0.140.0060.00616.81
8.0.130.0030.00313.30
8.0.120.0040.00416.78
8.0.110.0000.00916.88
8.0.100.0000.00716.95
8.0.90.0040.00416.97
8.0.80.0150.00616.86
8.0.70.0000.00716.89
8.0.60.0070.00016.86
8.0.50.0000.00716.88
8.0.30.0100.01017.12
8.0.20.0070.01717.40
8.0.10.0050.00216.85
8.0.00.0080.00816.87
7.4.330.0020.00214.72
7.4.320.0040.00416.66
7.4.300.0060.00016.60
7.4.290.0060.00016.64
7.4.280.0040.00416.43
7.4.270.0000.00716.49
7.4.260.0030.00313.16
7.4.250.0090.00016.59
7.4.240.0030.00316.63
7.4.230.0000.00716.50
7.4.220.0070.01316.71
7.4.210.0090.00716.56
7.4.200.0040.00416.71
7.4.190.0050.00316.78
7.4.160.0000.01716.45
7.4.150.0030.01517.40
7.4.140.0100.00717.14
7.4.130.0110.00916.43
7.4.120.0100.00716.52
7.4.110.0070.01016.42
7.4.100.0120.00916.51
7.4.90.0100.00716.55
7.4.80.0100.00619.03
7.4.70.0100.00716.52
7.4.60.0030.01316.46
7.4.50.0060.00016.72
7.4.40.0060.00722.27
7.4.30.0080.00816.37
7.4.00.0090.00914.93
7.3.330.0050.00013.35
7.3.320.0000.00513.34
7.3.310.0070.00016.35
7.3.300.0070.00016.25
7.3.290.0040.01116.40
7.3.280.0070.00816.35
7.3.270.0120.00817.40
7.3.260.0100.00918.24
7.3.250.0070.01616.45
7.3.240.0120.00616.59
7.3.230.0060.01116.42
7.3.210.0100.00716.61
7.3.200.0060.01319.39
7.3.190.0090.01216.57
7.3.180.0060.01516.37
7.3.170.0100.00716.46
7.3.160.0100.00616.50
7.3.120.0070.00714.99
7.3.110.0090.00914.71
7.3.100.0100.00715.01
7.3.90.0000.01415.08
7.3.80.0070.01114.78
7.3.70.0060.00614.86
7.3.60.0090.00614.49
7.3.50.0030.00614.86
7.3.40.0090.00014.61
7.3.30.0120.00014.74
7.3.20.0040.00816.73
7.3.10.0040.00716.75
7.3.00.0100.00616.48
7.2.330.0130.00416.77
7.2.320.0110.00716.71
7.2.310.0000.02316.67
7.2.300.0130.00316.31
7.2.290.0100.00616.62
7.2.250.0080.00815.13
7.2.240.0090.00614.69
7.2.230.0040.01115.36
7.2.220.0100.00715.15
7.2.210.0060.01015.11
7.2.200.0000.00915.07
7.2.190.0030.00915.07
7.2.180.0030.00915.06
7.2.170.0040.01114.98
7.2.160.0060.00615.08
7.2.150.0030.01016.80
7.2.140.0030.01317.08
7.2.130.0030.01417.04
7.2.120.0000.01216.75
7.2.110.0090.00617.02
7.2.100.0130.00316.79
7.2.90.0040.01417.04
7.2.80.0150.00316.76
7.2.70.0000.01516.76
7.2.60.0030.01016.88
7.2.50.0060.00316.93
7.2.40.0070.00717.07
7.2.30.0000.00917.05
7.2.20.0000.01617.02
7.2.10.0060.00617.05
7.2.00.0020.01317.86
7.1.330.0100.00616.05
7.1.320.0040.00715.86
7.1.310.0090.00615.85
7.1.300.0000.01115.75
7.1.290.0060.00615.85
7.1.280.0030.00916.00
7.1.270.0070.00715.77
7.1.260.0000.01215.68
7.1.250.0040.00715.72
7.1.240.0080.00515.61
7.1.230.0070.00715.87
7.1.220.0000.00815.79
7.1.210.0060.00915.86
7.1.200.0090.00015.70
7.1.190.0030.00615.82
7.1.180.0090.00615.82
7.1.170.0070.00415.94
7.1.160.0060.00515.73
7.1.150.0070.01015.82
7.1.140.0070.00715.50
7.1.130.0060.00615.84
7.1.120.0000.01415.77
7.1.110.0000.01015.58
7.1.100.0050.00716.78
7.1.90.0040.01115.87
7.1.80.0040.00415.97
7.1.70.0030.01116.51
7.1.60.0090.01017.45
7.1.50.0030.01216.42
7.1.40.0000.01415.93
7.1.30.0030.00615.63
7.1.20.0040.01115.54
7.1.10.0040.00415.73
7.1.00.0060.03518.95
7.0.330.0070.00415.36
7.0.320.0060.00615.49
7.0.310.0060.00615.50
7.0.300.0030.00915.25
7.0.290.0040.01215.38
7.0.280.0040.01215.21
7.0.270.0080.00315.54
7.0.260.0030.01015.22
7.0.250.0060.00315.41
7.0.240.0030.01015.48
7.0.230.0040.00415.47
7.0.220.0030.00615.45
7.0.210.0040.00815.38
7.0.200.0150.00215.96
7.0.190.0040.00715.32
7.0.180.0060.00915.45
7.0.170.0080.00015.39
7.0.160.0090.00615.24
7.0.150.0060.00615.44
7.0.140.0050.03718.70
7.0.130.0030.00815.54
7.0.120.0100.00315.39
7.0.110.0060.01015.43
7.0.100.0000.01315.46
7.0.90.0030.00815.48
7.0.80.0030.01015.58
7.0.70.0090.00315.69
7.0.60.0090.04017.73
7.0.50.0020.02516.84
7.0.40.0050.02315.93
7.0.30.0070.02315.93
7.0.20.0030.03515.91
7.0.10.0060.03115.92
7.0.00.0050.04415.90
5.6.400.0000.01314.52
5.6.390.0030.00614.57
5.6.380.0040.01114.64
5.6.370.0070.00714.39
5.6.360.0100.00714.34
5.6.350.0030.01014.71
5.6.340.0070.00714.43
5.6.330.0100.00314.57
5.6.320.0070.00314.43
5.6.310.0060.00914.10
5.6.300.0060.00914.72
5.6.290.0000.00914.50
5.6.280.0090.03717.73
5.6.270.0070.01014.41
5.6.260.0030.01214.12
5.6.250.0030.01314.31
5.6.240.0060.00614.66
5.6.230.0000.01614.43
5.6.220.0000.01414.47
5.6.210.0090.04217.69
5.6.200.0060.02116.29
5.6.190.0040.02416.32
5.6.180.0090.02416.32
5.6.170.0080.02016.14
5.6.160.0110.02616.43
5.6.150.0090.01816.16
5.6.140.0050.02816.31
5.6.130.0070.04416.40
5.6.120.0050.05016.32
5.6.110.0030.04116.29
5.6.100.0040.02516.26
5.6.90.0050.03016.39
5.6.80.0050.03715.96
5.6.70.0080.04116.00
5.6.60.0050.04615.96
5.6.50.0070.02615.86
5.6.40.0030.02915.98
5.6.30.0030.03716.11
5.6.20.0110.04015.93
5.6.10.0080.03315.84
5.6.00.0050.02915.81
5.5.380.0060.00614.22
5.5.370.0040.00714.70
5.5.360.0000.01114.27
5.5.350.0150.03617.33
5.5.340.0060.02116.41
5.5.330.0070.02016.04
5.5.320.0050.02316.11
5.5.310.0080.02116.27
5.5.300.0050.04816.12
5.5.290.0090.03816.14
5.5.280.0080.02816.26
5.5.270.0020.02816.21
5.5.260.0070.02716.13
5.5.250.0110.04116.09
5.5.240.0080.04315.86
5.5.230.0100.03515.72
5.5.220.0060.03315.74
5.5.210.0080.03815.87
5.5.200.0020.03015.73
5.5.190.0070.04415.78
5.5.180.0080.04015.80
5.5.170.0100.00614.10
5.5.160.0020.02915.85
5.5.150.0090.03015.86
5.5.140.0080.02515.95
5.5.130.0080.02815.71
5.5.120.0080.04115.69
5.5.110.0080.03315.94
5.5.100.0080.03315.91
5.5.90.0070.02515.70
5.5.80.0050.02815.66
5.5.70.0030.03015.72
5.5.60.0050.04115.72
5.5.50.0030.04215.74
5.5.40.0010.04615.81
5.5.30.0030.03515.71
5.5.20.0100.03915.77
5.5.10.0050.03015.71
5.5.00.0110.01915.71
5.4.450.0000.03916.72
5.4.440.0090.02216.78
5.4.430.0110.03516.72
5.4.420.0040.03816.77
5.4.410.0050.04016.64
5.4.400.0070.04416.58
5.4.390.0050.02516.53
5.4.380.0070.02016.55
5.4.370.0020.03916.58
5.4.360.0080.03516.61
5.4.350.0080.04016.60
5.4.340.0090.03816.58
5.4.330.0000.00914.10
5.4.320.0080.04016.58
5.4.310.0020.03016.60
5.4.300.0030.03916.59
5.4.290.0110.03616.57
5.4.280.0070.03116.56
5.4.270.0080.04016.56
5.4.260.0050.04316.56
5.4.250.0050.03316.49
5.4.240.0050.03816.59
5.4.230.0080.03216.57
5.4.220.0110.03816.52
5.4.210.0050.03216.53
5.4.200.0040.04216.60
5.4.190.0110.03516.61
5.4.180.0040.03216.59
5.4.170.0070.02216.60
5.4.160.0070.02116.56
5.4.150.0120.02816.55
5.4.140.0090.03315.26
5.4.130.0080.03515.21
5.4.120.0070.03815.24
5.4.110.0050.03815.26
5.4.100.0090.03015.27
5.4.90.0080.02515.22
5.4.80.0100.03015.26
5.4.70.0040.02015.21
5.4.60.0080.01815.26
5.4.50.0020.04215.15
5.4.40.0050.02315.26
5.4.30.0080.03515.22
5.4.20.0070.02515.31
5.4.10.0080.04015.18
5.4.00.0050.03814.96
5.3.290.0050.03014.31
5.3.280.0030.02814.33
5.3.270.0050.02414.28
5.3.260.0060.03314.37
5.3.250.0020.03814.28
5.3.240.0120.02714.40
5.3.230.0050.04014.33
5.3.220.0030.03514.36
5.3.210.0100.04014.33
5.3.200.0060.03814.38
5.3.190.0030.04414.36
5.3.180.0030.04414.35
5.3.170.0020.02914.32
5.3.160.0070.02514.35
5.3.150.0080.03214.35
5.3.140.0070.03214.32
5.3.130.0090.03914.38
5.3.120.0060.04414.25
5.3.110.0120.03314.44
5.3.100.0050.03314.09
5.3.90.0020.04114.04
5.3.80.0070.03813.98
5.3.70.0000.04614.01
5.3.60.0040.02414.09
5.3.50.0090.03214.13
5.3.40.0050.02214.04
5.3.30.0050.03714.04
5.3.20.0020.04013.92
5.3.10.0020.03513.93
5.3.00.0070.04013.79
5.2.170.0170.05711.23
5.2.160.0000.03711.22
5.2.150.0070.06311.25
5.2.140.0000.07011.17
5.2.130.0030.06011.13
5.2.120.0070.05311.18
5.2.110.0100.06011.32
5.2.100.0030.06011.10
5.2.90.0070.05711.16
5.2.80.0100.04711.09
5.2.70.0070.05011.30
5.2.60.0000.05311.08
5.2.50.0030.06310.90
5.2.40.0030.06010.89
5.2.30.0000.06711.03
5.2.20.0030.06310.93
5.2.10.0100.05710.94
5.2.00.0030.04710.80
5.1.60.0030.04710.20
5.1.50.0070.05010.04
5.1.40.0100.04710.02
5.1.30.0070.05310.41
5.1.20.0000.03010.34
5.1.10.0070.02310.04
5.1.00.0070.05310.15
5.0.50.0070.0438.55
5.0.40.0000.0438.39
5.0.30.0070.0478.15
5.0.20.0000.0338.21
5.0.10.0030.0478.25
5.0.00.0100.0578.09
4.4.90.0000.0377.68
4.4.80.0070.0307.68
4.4.70.0070.0237.68
4.4.60.0030.0207.68
4.4.50.0100.0137.68
4.4.40.0030.0477.68
4.4.30.0000.0377.68
4.4.20.0030.0137.68
4.4.10.0070.0207.68
4.4.00.0030.0277.68
4.3.110.0030.0377.68
4.3.100.0030.0277.68
4.3.90.0000.0207.68
4.3.80.0000.0507.68
4.3.70.0000.0307.68
4.3.60.0000.0337.68
4.3.50.0000.0337.68
4.3.40.0000.0537.68
4.3.30.0030.0277.68
4.3.20.0000.0407.68
4.3.10.0000.0237.68
4.3.00.0030.0337.68

preferences:
70.51 ms | 401 KiB | 5 Q