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;} echo '$i = ' . $i . ' $offset = ' . $offset . ' $iterations = '; $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.0090.01318.68
8.3.50.0120.00721.33
8.3.40.0090.00618.85
8.3.30.0180.00018.67
8.3.20.0060.00318.83
8.3.10.0000.00820.97
8.3.00.0000.00823.43
8.2.180.0040.01416.63
8.2.170.0090.00622.96
8.2.160.0070.00720.35
8.2.150.0050.00324.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0080.00021.05
8.2.110.0030.00620.38
8.2.100.0100.00318.03
8.2.90.0080.00019.17
8.2.80.0050.00317.97
8.2.70.0080.00017.63
8.2.60.0040.00417.93
8.2.50.0000.00918.07
8.2.40.0000.00818.34
8.2.30.0050.00321.13
8.2.20.0070.00317.87
8.2.10.0050.00317.71
8.2.00.0030.00517.68
8.1.280.0040.01125.92
8.1.270.0050.00323.99
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0090.00022.19
8.1.230.0000.01117.52
8.1.220.0040.00417.77
8.1.210.0050.00318.77
8.1.200.0060.00317.23
8.1.190.0000.00817.41
8.1.180.0040.00418.10
8.1.170.0000.00818.49
8.1.160.0040.00418.98
8.1.150.0000.00718.72
8.1.140.0000.00817.49
8.1.130.0000.00717.84
8.1.120.0070.00417.48
8.1.110.0070.00017.52
8.1.100.0030.00317.40
8.1.90.0000.00717.56
8.1.80.0040.00417.52
8.1.70.0000.00717.45
8.1.60.0000.00817.65
8.1.50.0030.00717.46
8.1.40.0000.00717.56
8.1.30.0000.00817.69
8.1.20.0040.00417.70
8.1.10.0030.00517.43
8.1.00.0040.00417.48
8.0.300.0040.00418.77
8.0.290.0030.00516.88
8.0.280.0000.00718.58
8.0.270.0070.00017.31
8.0.260.0060.00316.91
8.0.250.0000.00816.94
8.0.240.0000.00916.95
8.0.230.0030.00316.87
8.0.220.0060.00316.96
8.0.210.0070.00016.93
8.0.200.0070.00016.96
8.0.190.0030.00416.96
8.0.180.0040.00416.89
8.0.170.0000.00816.96
8.0.160.0020.00516.86
8.0.150.0080.00016.87
8.0.140.0070.00016.89
8.0.130.0000.00713.34
8.0.120.0040.00416.87
8.0.110.0070.00016.92
8.0.100.0040.00416.93
8.0.90.0000.00816.73
8.0.80.0070.00716.85
8.0.70.0000.00916.88
8.0.60.0000.00817.05
8.0.50.0000.00816.94
8.0.30.0070.01217.24
8.0.20.0150.00617.40
8.0.10.0050.00317.15
8.0.00.0070.01116.80
7.4.330.0000.00614.66
7.4.320.0030.00316.54
7.4.300.0030.00316.69
7.4.290.0070.00016.54
7.4.280.0050.00316.55
7.4.270.0000.00716.62
7.4.260.0050.00013.35
7.4.250.0040.00416.52
7.4.240.0050.00216.48
7.4.230.0050.00316.63
7.4.220.0100.00816.60
7.4.210.0070.00816.68
7.4.200.0060.00316.74
7.4.190.0030.00316.60
7.4.160.0160.00016.42
7.4.150.0040.01417.40
7.4.140.0170.00517.86
7.4.130.0100.00916.60
7.4.120.0090.00916.65
7.4.110.0120.00616.49
7.4.100.0140.00716.56
7.4.90.0170.00316.65
7.4.80.0080.00819.39
7.4.70.0110.00716.38
7.4.60.0060.01016.52
7.4.50.0030.00616.68
7.4.40.0060.00622.52
7.4.30.0140.00316.21
7.4.00.0060.01114.88
7.3.330.0000.00613.39
7.3.320.0000.00613.41
7.3.310.0000.00716.36
7.3.300.0040.00416.27
7.3.290.0150.00016.39
7.3.280.0080.01016.41
7.3.270.0130.00417.40
7.3.260.0060.01318.24
7.3.250.0110.01016.58
7.3.240.0090.01016.63
7.3.230.0030.01316.40
7.3.210.0070.01016.39
7.3.200.0070.01119.39
7.3.190.0040.01516.43
7.3.180.0090.01616.39
7.3.170.0060.01316.36
7.3.160.0120.00416.64
7.3.120.0070.01114.87
7.3.110.0110.00714.74
7.3.100.0070.01015.10
7.3.90.0080.00815.06
7.3.80.0040.01414.94
7.3.70.0030.01014.61
7.3.60.0000.01114.93
7.3.50.0050.00515.07
7.3.40.0040.01114.83
7.3.30.0030.01015.06
7.3.20.0000.01216.64
7.3.10.0030.01016.53
7.3.00.0080.00716.72
7.2.330.0100.01016.52
7.2.320.0060.01316.45
7.2.310.0070.01116.75
7.2.300.0130.01016.78
7.2.290.0160.00916.72
7.2.250.0070.01415.23
7.2.240.0030.01714.87
7.2.230.0070.00715.00
7.2.220.0120.00314.87
7.2.210.0070.01015.03
7.2.200.0000.01415.26
7.2.190.0060.00315.13
7.2.180.0040.01114.91
7.2.170.0030.00615.08
7.2.160.0000.00915.21
7.2.150.0030.01616.66
7.2.140.0040.01116.91
7.2.130.0030.01216.76
7.2.120.0010.01016.88
7.2.110.0000.01116.72
7.2.100.0080.00516.93
7.2.90.0040.00816.98
7.2.80.0060.00917.05
7.2.70.0070.01016.89
7.2.60.0080.00516.88
7.2.50.0070.00616.89
7.2.40.0080.00516.79
7.2.30.0050.00916.93
7.2.20.0020.01616.92
7.2.10.0050.00716.86
7.2.00.0090.00817.68
7.1.330.0040.01215.96
7.1.320.0060.00915.92
7.1.310.0000.01215.92
7.1.300.0000.00915.65
7.1.290.0080.00415.61
7.1.280.0040.00415.82
7.1.270.0070.00315.75
7.1.260.0060.00615.93
7.1.250.0050.00715.59
7.1.240.0000.01415.78
7.1.230.0030.00915.71
7.1.220.0070.00715.77
7.1.210.0080.00315.77
7.1.200.0040.01115.62
7.1.190.0030.00915.88
7.1.180.0030.01015.90
7.1.170.0080.00515.57
7.1.160.0100.00315.91
7.1.150.0030.01316.05
7.1.140.0000.01515.80
7.1.130.0030.00615.76
7.1.120.0070.00715.79
7.1.110.0060.00615.88
7.1.100.0070.00717.09
7.1.90.0000.01115.91
7.1.80.0060.00615.89
7.1.70.0060.00416.51
7.1.60.0070.01317.68
7.1.50.0060.01416.42
7.1.40.0110.00415.93
7.1.30.0000.01215.87
7.1.20.0110.00415.66
7.1.10.0070.00715.74
7.1.00.0060.02019.15
7.0.330.0000.00915.49
7.0.320.0030.01015.46
7.0.310.0030.00715.63
7.0.300.0060.00615.50
7.0.290.0090.00615.49
7.0.280.0030.01215.23
7.0.270.0070.00315.07
7.0.260.0100.00315.41
7.0.250.0040.00415.32
7.0.240.0050.00515.35
7.0.230.0050.00315.44
7.0.220.0030.00915.25
7.0.210.0090.00415.35
7.0.200.0050.00416.10
7.0.190.0000.01215.43
7.0.180.0060.00615.46
7.0.170.0040.00715.55
7.0.160.0070.01015.46
7.0.150.0090.00615.50
7.0.140.0060.03618.78
7.0.130.0070.01115.43
7.0.120.0070.00715.57
7.0.110.0100.04017.64
7.0.100.0040.03317.75
7.0.90.0100.02717.71
7.0.80.0050.03017.65
7.0.70.0080.02817.66
7.0.60.0050.02817.66
7.0.50.0090.03917.81
7.0.40.0030.02416.72
7.0.30.0030.02816.62
7.0.20.0100.04316.54
7.0.10.0030.02916.58
7.0.00.0020.04516.67
5.6.400.0040.00714.57
5.6.390.0070.00714.69
5.6.380.0060.00314.21
5.6.370.0060.01214.54
5.6.360.0070.00714.26
5.6.350.0060.00614.33
5.6.340.0030.01014.50
5.6.330.0100.00314.65
5.6.320.0140.00314.25
5.6.310.0100.00314.63
5.6.300.0040.00714.32
5.6.290.0050.00314.43
5.6.280.0110.03817.74
5.6.270.0070.00714.53
5.6.260.0070.04617.63
5.6.250.0060.02917.52
5.6.240.0050.03217.55
5.6.230.0100.04517.36
5.6.220.0140.03517.51
5.6.210.0080.02517.40
5.6.200.0060.02317.55
5.6.190.0060.02417.55
5.6.180.0090.04217.59
5.6.170.0030.02817.55
5.6.160.0060.02517.73
5.6.150.0070.03517.46
5.6.140.0080.02217.58
5.6.130.0120.03517.42
5.6.120.0070.02117.68
5.6.110.0070.02017.48
5.6.100.0050.04317.58
5.6.90.0080.02017.69
5.6.80.0080.02117.28
5.6.70.0080.02017.11
5.6.60.0070.03817.26
5.6.50.0020.03617.14
5.6.40.0020.03317.19
5.6.30.0020.04117.17
5.6.20.0040.04317.25
5.6.10.0030.03517.18
5.6.00.0110.04017.09
5.5.380.0100.03716.05
5.5.370.0070.02816.01
5.5.360.0080.04016.04
5.5.350.0060.02716.04
5.5.340.0100.02716.16
5.5.330.0020.02716.27
5.5.320.0070.02716.18
5.5.310.0050.04316.06
5.5.300.0080.02515.94
5.5.290.0030.03516.16
5.5.280.0050.02916.37
5.5.270.0070.04616.23
5.5.260.0050.02816.24
5.5.250.0100.03716.17
5.5.240.0030.03515.96
5.5.230.0020.03715.68
5.5.220.0070.04015.89
5.5.210.0030.02216.02
5.5.200.0070.03515.81
5.5.190.0050.02815.71
5.5.180.0030.04315.80
5.5.170.0040.01114.15
5.5.160.0010.02315.81
5.5.150.0000.04215.73
5.5.140.0030.03015.79
5.5.130.0030.02615.81
5.5.120.0090.01915.84
5.5.110.0080.02815.96
5.5.100.0080.02215.79
5.5.90.0090.03615.87
5.5.80.0030.04715.65
5.5.70.0130.03515.63
5.5.60.0090.01915.91
5.5.50.0030.02515.69
5.5.40.0080.03515.76
5.5.30.0070.02015.70
5.5.20.0110.04015.88
5.5.10.0050.03515.84
5.5.00.0090.03715.81
5.4.450.0070.03416.24
5.4.440.0080.01816.16
5.4.430.0070.02016.30
5.4.420.0050.02316.20
5.4.410.0060.03316.10
5.4.400.0030.01916.02
5.4.390.0030.02316.00
5.4.380.0020.04616.12
5.4.370.0070.03716.07
5.4.360.0050.02716.11
5.4.350.0030.02216.03
5.4.340.0110.01716.11
5.4.330.0030.00913.05
5.4.320.0030.04516.04
5.4.310.0080.04316.02
5.4.300.0060.03116.18
5.4.290.0060.03116.03
5.4.280.0020.02116.02
5.4.270.0060.01916.04
5.4.260.0090.02416.07
5.4.250.0050.02316.03
5.4.240.0040.04316.03
5.4.230.0080.01716.09
5.4.220.0050.03816.09
5.4.210.0040.02316.11
5.4.200.0030.02216.11
5.4.190.0090.03016.02
5.4.180.0080.02016.01
5.4.170.0060.02316.11
5.4.160.0070.02516.02
5.4.150.0070.02516.17
5.4.140.0030.02614.70
5.4.130.0030.02814.74
5.4.120.0030.03314.80
5.4.110.0000.02614.84
5.4.100.0080.02314.76
5.4.90.0080.02114.73
5.4.80.0060.01814.77
5.4.70.0050.02014.73
5.4.60.0070.01814.75
5.4.50.0060.02214.64
5.4.40.0030.02514.81
5.4.30.0050.02714.80
5.4.20.0050.02514.74
5.4.10.0080.02014.73
5.4.00.0040.03614.52
5.3.290.0100.04113.89
5.3.280.0060.03813.87
5.3.270.0080.03313.77
5.3.260.0050.03513.81
5.3.250.0050.01913.89
5.3.240.0080.01813.83
5.3.230.0030.02213.80
5.3.220.0040.02413.82
5.3.210.0030.03813.79
5.3.200.0020.02313.82
5.3.190.0030.03613.88
5.3.180.0060.01813.83
5.3.170.0030.03813.85
5.3.160.0050.03613.80
5.3.150.0010.02313.80
5.3.140.0000.03113.82
5.3.130.0030.02313.80
5.3.120.0080.03713.78
5.3.110.0040.02213.85
5.3.100.0080.03013.54
5.3.90.0060.03713.60
5.3.80.0000.02913.53
5.3.70.0030.03713.53
5.3.60.0020.02413.54
5.3.50.0020.02113.49
5.3.40.0020.02713.57
5.3.30.0030.02213.52
5.3.20.0040.03213.44
5.3.10.0050.03113.39
5.3.00.0030.02013.41
5.2.170.0000.03012.21
5.2.160.0030.03012.21
5.2.150.0000.03012.21
5.2.140.0000.03712.21
5.2.130.0000.05312.21
5.2.120.0070.02312.21
5.2.110.0070.06012.21
5.2.100.0070.03012.21
5.2.90.0000.07012.21
5.2.80.0030.03312.21
5.2.70.0030.02712.21
5.2.60.0030.02712.21
5.2.50.0130.04012.21
5.2.40.0000.03012.21
5.2.30.0000.03012.21
5.2.20.0030.03712.21
5.2.10.0030.02712.21
5.2.00.0000.03012.21
5.1.60.0030.02312.21
5.1.50.0030.02312.21
5.1.40.0000.02012.21
5.1.30.0030.02712.21
5.1.20.0130.01712.21
5.1.10.0000.04312.21
5.1.00.0030.02312.21
5.0.50.0030.02012.21
5.0.40.0000.02012.21
5.0.30.0030.04012.21
5.0.20.0000.03012.21
5.0.10.0030.04012.21
5.0.00.0030.04712.21
4.4.90.0030.03712.21
4.4.80.0000.02012.21
4.4.70.0070.01012.21
4.4.60.0100.00712.21
4.4.50.0000.01712.21
4.4.40.0000.02312.21
4.4.30.0000.01712.21
4.4.20.0000.01712.21
4.4.10.0000.03712.21
4.4.00.0000.02312.21
4.3.110.0000.02312.21
4.3.100.0030.03712.21
4.3.90.0000.01712.21
4.3.80.0030.04312.21
4.3.70.0000.01712.21
4.3.60.0000.01312.21
4.3.50.0030.02312.21
4.3.40.0100.03712.21
4.3.30.0030.01312.21
4.3.20.0030.03712.21
4.3.10.0000.03312.21
4.3.00.0000.01712.21

preferences:
38.36 ms | 401 KiB | 5 Q