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[$i] = $fizzbuzz;} elseif($i % $buzz_int == 0){ $ret[$i] = $buzz;} elseif($i % $fizz_int == 0){ $ret[$i] = $fizz;} else{ $ret[$i] = $i;} $i++; } return $ret; } print_r(fizzbuzz(200, 6, 'something', 'stuff', 'darkside', 5, 7, 17));

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.0150.00618.18
8.3.50.0080.01022.05
8.3.40.0100.00318.91
8.3.30.0160.00318.47
8.3.20.0050.00318.64
8.3.10.0000.00819.51
8.3.00.0000.00823.61
8.2.180.0110.00718.29
8.2.170.0100.01022.96
8.2.160.0100.00320.52
8.2.150.0090.00024.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0050.00319.65
8.2.110.0050.00521.07
8.2.100.0080.00317.91
8.2.90.0030.00519.16
8.2.80.0040.00417.97
8.2.70.0030.00617.63
8.2.60.0080.00018.04
8.2.50.0040.00418.10
8.2.40.0050.00318.18
8.2.30.0040.00421.10
8.2.20.0040.00417.76
8.2.10.0020.00517.64
8.2.00.0100.00017.77
8.1.280.0060.00925.92
8.1.270.0060.00323.99
8.1.260.0000.00826.35
8.1.250.0080.00328.09
8.1.240.0090.00021.30
8.1.230.0070.00417.70
8.1.220.0000.00817.79
8.1.210.0090.00018.77
8.1.200.0040.00417.35
8.1.190.0030.00617.23
8.1.180.0040.00418.10
8.1.170.0050.00318.59
8.1.160.0000.00718.88
8.1.150.0000.00818.54
8.1.140.0000.00717.50
8.1.130.0030.00317.85
8.1.120.0000.00817.40
8.1.110.0040.00417.37
8.1.100.0040.00317.54
8.1.90.0000.00717.38
8.1.80.0000.00717.50
8.1.70.0000.00717.44
8.1.60.0050.00317.66
8.1.50.0000.00817.48
8.1.40.0070.00317.50
8.1.30.0040.00417.59
8.1.20.0000.00817.70
8.1.10.0000.00717.68
8.1.00.0040.00417.54
8.0.300.0040.00418.77
8.0.290.0000.00716.75
8.0.280.0030.00518.39
8.0.270.0030.00317.24
8.0.260.0060.00316.82
8.0.250.0000.00716.98
8.0.240.0050.00316.99
8.0.230.0000.00716.91
8.0.220.0070.00016.80
8.0.210.0030.00316.92
8.0.200.0060.00017.01
8.0.190.0050.00216.99
8.0.180.0000.00817.01
8.0.170.0080.00016.83
8.0.160.0070.00016.90
8.0.150.0000.00716.93
8.0.140.0000.00716.84
8.0.130.0030.00313.34
8.0.120.0030.00516.93
8.0.110.0040.00416.84
8.0.100.0020.00516.81
8.0.90.0030.00616.72
8.0.80.0090.00916.96
8.0.70.0000.00816.98
8.0.60.0050.00316.96
8.0.50.0030.00516.87
8.0.30.0100.00917.06
8.0.20.0150.00717.40
8.0.10.0050.00316.94
8.0.00.0090.01116.90
7.4.330.0060.00014.82
7.4.320.0040.00416.66
7.4.300.0040.00416.49
7.4.290.0070.00016.54
7.4.280.0080.00016.52
7.4.270.0000.00716.49
7.4.260.0000.00513.44
7.4.250.0000.00816.51
7.4.240.0030.00316.61
7.4.230.0000.00716.56
7.4.220.0100.01316.52
7.4.210.0110.00716.67
7.4.200.0030.00316.57
7.4.190.0040.00416.63
7.4.160.0030.01516.66
7.4.150.0050.01417.40
7.4.140.0070.01417.86
7.4.130.0090.00816.48
7.4.120.0090.00916.55
7.4.110.0120.00416.46
7.4.100.0110.00516.66
7.4.90.0100.00716.34
7.4.80.0090.00619.39
7.4.70.0130.01016.50
7.4.60.0110.00716.44
7.4.50.0060.00316.38
7.4.40.0000.01822.52
7.4.30.0040.01316.57
7.4.00.0040.01414.94
7.3.330.0050.00013.17
7.3.320.0050.00013.38
7.3.310.0080.00016.43
7.3.300.0000.00716.41
7.3.290.0080.00816.39
7.3.280.0110.00516.37
7.3.270.0170.00017.40
7.3.260.0100.01018.24
7.3.250.0060.01516.44
7.3.240.0060.01016.48
7.3.230.0180.00016.66
7.3.210.0070.01116.61
7.3.200.0060.01019.39
7.3.190.0150.00616.49
7.3.180.0070.01016.64
7.3.170.0080.00816.46
7.3.160.0120.00416.47
7.3.120.0080.00914.97
7.3.110.0070.00914.80
7.3.100.0030.01414.85
7.3.90.0050.00614.74
7.3.80.0070.00914.83
7.3.70.0070.00514.90
7.3.60.0050.00815.00
7.3.50.0050.00814.88
7.3.40.0060.00414.93
7.3.30.0040.01115.01
7.3.20.0070.00616.65
7.3.10.0030.00816.64
7.3.00.0050.00916.64
7.2.330.0110.00616.51
7.2.320.0130.01016.46
7.2.310.0130.00416.34
7.2.300.0110.00516.29
7.2.290.0130.00416.77
7.2.250.0070.01015.27
7.2.240.0050.01514.98
7.2.230.0040.01015.07
7.2.220.0060.00615.03
7.2.210.0050.01015.18
7.2.200.0030.00915.11
7.2.190.0060.00814.79
7.2.180.0070.00514.90
7.2.170.0030.00915.10
7.2.160.0060.01215.08
7.2.150.0130.00017.04
7.2.140.0030.01017.03
7.2.130.0060.01016.59
7.2.120.0100.01016.89
7.2.110.0100.00316.97
7.2.100.0060.01016.55
7.2.90.0030.00917.00
7.2.80.0000.01416.96
7.2.70.0080.00516.78
7.2.60.0040.01116.77
7.2.50.0100.00716.95
7.2.40.0060.00916.96
7.2.30.0070.00716.75
7.2.20.0080.00816.76
7.2.10.0110.00617.03
7.2.00.0090.00718.01
7.1.330.0050.00815.70
7.1.320.0100.00215.70
7.1.310.0050.00915.85
7.1.300.0050.00815.78
7.1.290.0060.00415.86
7.1.280.0050.00615.74
7.1.270.0070.00415.82
7.1.260.0030.00816.00
7.1.250.0070.00715.78
7.1.240.0070.01015.79
7.1.230.0040.01115.77
7.1.220.0070.01015.77
7.1.210.0080.00615.98
7.1.200.0060.00915.94
7.1.190.0000.01215.93
7.1.180.0030.01015.79
7.1.170.0000.01615.96
7.1.160.0000.00915.91
7.1.150.0030.00815.78
7.1.140.0030.01015.76
7.1.130.0100.00315.73
7.1.120.0030.00715.91
7.1.110.0000.01315.91
7.1.100.0050.00816.84
7.1.90.0000.01516.05
7.1.80.0040.01115.75
7.1.70.0080.00816.47
7.1.60.0080.00917.67
7.1.50.0070.01016.27
7.1.40.0000.01315.84
7.1.30.0000.01615.81
7.1.20.0040.01115.95
7.1.10.0060.00615.77
7.1.00.0070.03319.09
7.0.330.0100.01015.39
7.0.320.0090.00315.48
7.0.310.0070.01015.28
7.0.300.0100.00715.62
7.0.290.0070.01015.21
7.0.280.0100.00715.59
7.0.270.0110.00715.47
7.0.260.0070.01315.50
7.0.250.0070.01015.50
7.0.240.0040.00715.43
7.0.230.0060.00615.56
7.0.220.0060.01215.44
7.0.210.0100.01015.55
7.0.200.0070.00516.13
7.0.190.0040.00815.49
7.0.180.0000.01615.48
7.0.170.0030.01415.57
7.0.160.0030.00915.51
7.0.150.0030.01315.39
7.0.140.0030.04118.65
7.0.130.0040.01215.29
7.0.120.0030.01215.44
7.0.110.0050.02917.77
7.0.100.0080.02217.62
7.0.90.0160.03717.70
7.0.80.0150.01717.79
7.0.70.0070.02317.71
7.0.60.0080.02817.65
7.0.50.0110.03617.73
7.0.40.0130.01516.71
7.0.30.0090.04116.63
7.0.20.0030.03216.58
7.0.10.0120.02016.63
7.0.00.0100.02016.68
5.6.400.0000.01814.75
5.6.390.0160.00314.58
5.6.380.0040.01114.49
5.6.370.0120.00614.39
5.6.360.0120.00414.66
5.6.350.0060.00614.82
5.6.340.0060.01314.50
5.6.330.0100.01014.52
5.6.320.0100.00714.33
5.6.310.0030.01014.63
5.6.300.0110.00314.29
5.6.290.0060.00614.59
5.6.280.0070.04417.72
5.6.270.0030.01414.45
5.6.260.0060.01817.76
5.6.250.0080.03217.68
5.6.240.0060.03317.37
5.6.230.0090.02317.44
5.6.220.0050.02717.44
5.6.210.0060.02817.63
5.6.200.0080.02217.50
5.6.190.0030.02717.57
5.6.180.0110.01917.48
5.6.170.0060.02817.47
5.6.160.0110.02217.62
5.6.150.0050.02817.49
5.6.140.0120.02017.63
5.6.130.0080.02217.55
5.6.120.0060.02717.64
5.6.110.0120.03917.40
5.6.100.0070.04517.42
5.6.90.0090.04317.46
5.6.80.0080.02717.28
5.6.70.0030.04717.10
5.6.60.0130.04517.20
5.6.50.0150.03517.17
5.6.40.0100.03217.18
5.6.30.0070.02817.11
5.6.20.0070.02416.98
5.6.10.0050.04317.43
5.6.00.0050.04117.04
5.5.380.0080.02015.96
5.5.370.0040.02716.00
5.5.360.0070.02415.99
5.5.350.0070.02315.97
5.5.340.0070.02516.06
5.5.330.0080.02416.16
5.5.320.0030.02816.13
5.5.310.0030.03016.26
5.5.300.0030.02716.41
5.5.290.0080.03516.18
5.5.280.0000.03616.09
5.5.270.0070.04616.11
5.5.260.0050.04716.28
5.5.250.0070.04316.08
5.5.240.0110.03916.04
5.5.230.0080.04015.93
5.5.220.0080.03815.92
5.5.210.0050.02915.99
5.5.200.0070.02115.85
5.5.190.0070.02815.90
5.5.180.0020.03715.94
5.5.170.0100.00714.08
5.5.160.0070.04316.07
5.5.150.0120.02715.71
5.5.140.0040.02415.78
5.5.130.0060.04416.06
5.5.120.0070.04315.67
5.5.110.0070.04315.80
5.5.100.0030.04515.88
5.5.90.0070.03815.74
5.5.80.0050.04315.84
5.5.70.0070.02715.59
5.5.60.0080.03115.87
5.5.50.0110.04015.85
5.5.40.0100.03015.96
5.5.30.0020.04215.69
5.5.20.0060.03615.79
5.5.10.0100.03915.54
5.5.00.0080.03615.82
5.4.450.0020.02815.93
5.4.440.0030.04116.00
5.4.430.0050.03515.84
5.4.420.0100.03715.84
5.4.410.0090.02315.87
5.4.400.0120.03915.70
5.4.390.0080.03715.73
5.4.380.0070.04515.68
5.4.370.0070.03715.85
5.4.360.0070.02215.73
5.4.350.0080.03715.68
5.4.340.0100.02015.72
5.4.330.0030.00912.36
5.4.320.0080.03115.68
5.4.310.0050.03515.79
5.4.300.0070.03215.78
5.4.290.0070.04015.80
5.4.280.0060.04015.77
5.4.270.0100.03215.77
5.4.260.0050.04615.81
5.4.250.0070.02515.83
5.4.240.0060.04015.85
5.4.230.0080.02815.85
5.4.220.0100.03715.65
5.4.210.0050.03415.69
5.4.200.0110.03415.68
5.4.190.0120.03715.72
5.4.180.0050.04215.67
5.4.170.0050.04015.67
5.4.160.0090.02415.76
5.4.150.0020.05215.83
5.4.140.0050.04214.38
5.4.130.0120.03714.44
5.4.120.0090.02414.44
5.4.110.0050.02414.43
5.4.100.0100.03314.42
5.4.90.0050.02814.43
5.4.80.0070.02014.41
5.4.70.0030.02414.42
5.4.60.0050.03314.38
5.4.50.0060.01814.45
5.4.40.0030.03914.43
5.4.30.0030.02514.39
5.4.20.0030.03714.31
5.4.10.0070.04514.45
5.4.00.0120.03214.12
5.3.290.0020.04413.53
5.3.280.0070.04013.51
5.3.270.0100.04313.50
5.3.260.0080.03513.48
5.3.250.0150.03313.51
5.3.240.0110.04013.54
5.3.230.0080.02613.50
5.3.220.0040.02413.46
5.3.210.0040.02213.50
5.3.200.0050.03213.48
5.3.190.0090.04213.52
5.3.180.0100.01813.45
5.3.170.0110.01313.51
5.3.160.0060.01813.59
5.3.150.0030.03113.48
5.3.140.0100.01713.53
5.3.130.0100.04213.54
5.3.120.0080.04313.54
5.3.110.0050.02813.53
5.3.100.0070.04213.14
5.3.90.0020.02813.31
5.3.80.0050.02213.24
5.3.70.0020.02413.24
5.3.60.0070.02713.20
5.3.50.0060.04113.23
5.3.40.0040.02713.10
5.3.30.0070.02213.16
5.3.20.0050.02313.07
5.3.10.0030.02213.03
5.3.00.0050.02813.06
5.2.170.0070.04713.04
5.2.160.0000.07013.04
5.2.150.0000.03013.04
5.2.140.0070.06713.04
5.2.130.0030.04013.04
5.2.120.0000.03013.04
5.2.110.0100.04713.04
5.2.100.0000.03313.04
5.2.90.0100.05013.04
5.2.80.0070.06313.04
5.2.70.0070.03013.04
5.2.60.0000.05013.04
5.2.50.0070.05013.04
5.2.40.0070.04713.04
5.2.30.0070.04313.04
5.2.20.0070.05013.04
5.2.10.0030.07013.04
5.2.00.0170.04313.04
5.1.60.0070.04013.04
5.1.50.0000.05713.04
5.1.40.0100.05013.04
5.1.30.0000.03013.04
5.1.20.0130.05013.04
5.1.10.0030.06013.04
5.1.00.0070.04713.04
5.0.50.0100.04013.04
5.0.40.0100.03013.04
5.0.30.0070.03313.04
5.0.20.0030.04013.04
5.0.10.0000.03713.04
5.0.00.0000.04013.04
4.4.90.0030.03713.04
4.4.80.0070.03313.04
4.4.70.0030.01313.04
4.4.60.0000.02313.04
4.4.50.0030.02713.04
4.4.40.0100.03013.04
4.4.30.0000.01713.04
4.4.20.0000.03013.04
4.4.10.0030.03313.04
4.4.00.0030.05313.04
4.3.110.0030.03713.04
4.3.100.0070.03013.04
4.3.90.0030.03313.04
4.3.80.0000.04013.04
4.3.70.0000.02313.04
4.3.60.0070.03313.04
4.3.50.0030.03313.04
4.3.40.0070.04713.04
4.3.30.0030.03013.04
4.3.20.0000.04013.04
4.3.10.0070.02713.04
4.3.00.0070.01313.04

preferences:
38.79 ms | 401 KiB | 5 Q