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++; } return $ret; } 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.40.0070.00718.84
8.3.30.0030.01020.39
8.3.20.0050.00320.16
8.3.10.0080.00021.10
8.3.00.0080.00022.36
8.2.170.0070.00722.96
8.2.160.0100.00322.13
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0040.01520.88
8.2.110.0000.01020.46
8.2.100.0000.01118.04
8.2.90.0060.00318.22
8.2.80.0040.00419.30
8.2.70.0100.00317.63
8.2.60.0030.00518.05
8.2.50.0060.00318.07
8.2.40.0000.00818.15
8.2.30.0000.00719.33
8.2.20.0030.00517.59
8.2.10.0040.00417.67
8.2.00.0040.00417.76
8.1.270.0050.00323.99
8.1.260.0040.00426.35
8.1.250.0060.00328.09
8.1.240.0090.00022.19
8.1.230.0030.00720.95
8.1.220.0030.00517.74
8.1.210.0040.00418.95
8.1.200.0100.00017.35
8.1.190.0000.00817.51
8.1.180.0030.00518.10
8.1.170.0000.00918.71
8.1.160.0000.00718.91
8.1.150.0000.00818.57
8.1.140.0000.00817.49
8.1.130.0000.00717.89
8.1.120.0000.00817.36
8.1.110.0060.00317.49
8.1.100.0000.00817.40
8.1.90.0000.00717.41
8.1.80.0070.00017.36
8.1.70.0070.00017.36
8.1.60.0050.00317.59
8.1.50.0030.00617.50
8.1.40.0000.00717.51
8.1.30.0050.00317.60
8.1.20.0040.00417.68
8.1.10.0030.00517.58
8.1.00.0000.00817.36
8.0.300.0040.00420.04
8.0.290.0030.00517.05
8.0.280.0030.00318.42
8.0.270.0070.00017.34
8.0.260.0030.00316.85
8.0.250.0030.00616.96
8.0.240.0090.00016.89
8.0.230.0030.00316.93
8.0.220.0000.00716.86
8.0.210.0030.00316.87
8.0.200.0000.00616.97
8.0.190.0080.00016.93
8.0.180.0040.00416.92
8.0.170.0040.00416.87
8.0.160.0040.00416.78
8.0.150.0000.00716.89
8.0.140.0130.00216.80
8.0.130.0030.00313.41
8.0.120.0040.00416.85
8.0.110.0040.00416.95
8.0.100.0040.00416.98
8.0.90.0040.00416.81
8.0.80.0100.00716.95
8.0.70.0050.00316.98
8.0.60.0000.00716.97
8.0.50.0000.00716.88
8.0.30.0080.01117.13
8.0.20.0110.00817.43
8.0.10.0070.00016.84
8.0.00.0110.01616.79
7.4.330.0000.00516.74
7.4.320.0000.00716.59
7.4.300.0000.00616.66
7.4.290.0030.00516.44
7.4.280.0000.00716.61
7.4.270.0030.00316.42
7.4.260.0050.00013.41
7.4.250.0000.00716.59
7.4.240.0000.00716.52
7.4.230.0030.00316.61
7.4.220.0140.00416.61
7.4.210.0080.00716.55
7.4.200.0000.00716.43
7.4.190.0070.00016.75
7.4.160.0030.01316.40
7.4.150.0130.00717.40
7.4.140.0060.01317.86
7.4.130.0100.00616.56
7.4.120.0150.00516.57
7.4.110.0090.01216.59
7.4.100.0030.01316.61
7.4.90.0060.01616.57
7.4.80.0160.00319.39
7.4.70.0080.00816.54
7.4.60.0100.00616.60
7.4.50.0000.00816.49
7.4.40.0100.00522.77
7.4.30.0110.00516.53
7.4.00.0090.00614.86
7.3.330.0020.00213.18
7.3.320.0020.00213.38
7.3.310.0070.00016.37
7.3.300.0000.00716.25
7.3.290.0080.00616.30
7.3.280.0080.01016.35
7.3.270.0160.00317.40
7.3.260.0060.01318.24
7.3.250.0110.01116.61
7.3.240.0110.00616.43
7.3.230.0080.00816.39
7.3.210.0140.00316.40
7.3.200.0070.01119.39
7.3.190.0110.00616.32
7.3.180.0170.00316.46
7.3.170.0120.00916.46
7.3.160.0070.01016.66
7.3.120.0040.01214.67
7.3.00.0070.00716.80
7.2.330.0060.01216.80
7.2.320.0160.00616.64
7.2.310.0090.00916.77
7.2.300.0030.01516.37
7.2.290.0130.01016.59
7.2.130.0070.01016.73
7.2.120.0060.01216.59
7.2.110.0060.00616.91
7.2.100.0030.00616.70
7.2.90.0060.00616.60
7.2.80.0080.00316.64
7.2.70.0110.00016.61
7.2.60.0030.01217.01
7.2.50.0070.00416.88
7.2.40.0060.00616.94
7.2.30.0000.01317.01
7.2.20.0060.01116.79
7.2.10.0060.00616.52
7.2.00.0030.01216.96
7.1.250.0030.01315.70
7.1.240.0030.00615.79
7.1.230.0130.00015.40
7.1.220.0030.01015.79
7.1.210.0060.00615.67
7.1.200.0000.01015.89
7.1.190.0070.00715.67
7.1.180.0000.01315.76
7.1.170.0060.00616.00
7.1.160.0050.00815.66
7.1.150.0070.00715.98
7.1.140.0130.00315.82
7.1.130.0070.00415.76
7.1.120.0070.00315.89
7.1.110.0030.01015.57
7.1.100.0000.00915.68
7.1.90.0060.00915.52
7.1.80.0040.00815.89
7.1.70.0070.00616.54
7.1.60.0060.01317.50
7.1.50.0070.01216.52
7.1.40.0120.00616.00
7.1.30.0030.01115.67
7.1.20.0040.01115.73
7.1.10.0090.00315.56
7.1.00.0060.01819.06
7.0.330.0100.00615.45
7.0.320.0040.00715.27
7.0.310.0040.00815.50
7.0.300.0110.00415.43
7.0.290.0110.00715.39
7.0.280.0100.00315.43
7.0.270.0060.00915.43
7.0.260.0030.01215.41
7.0.250.0060.00615.44
7.0.240.0080.00315.61
7.0.230.0000.01515.51
7.0.220.0040.01115.62
7.0.210.0070.00715.32
7.0.200.0310.01015.03
7.0.190.0110.00415.47
7.0.180.0030.01015.33
7.0.170.0110.00715.13
7.0.160.0070.00715.17
7.0.150.0090.00315.40
7.0.140.0050.03918.67
7.0.130.0100.00715.50
7.0.120.0120.00315.20
7.0.110.0040.00815.61
7.0.100.0070.00715.20
7.0.90.0060.00915.48
7.0.80.0030.02717.67
7.0.70.0130.03717.65
7.0.60.0030.04717.64
7.0.50.0080.02817.95
7.0.40.0130.03816.71
7.0.30.0070.04716.84
7.0.20.0120.03216.72
7.0.10.0110.04016.80
7.0.00.0050.04816.79
5.6.380.0090.00614.48
5.6.370.0060.00614.44
5.6.360.0070.00714.30
5.6.350.0040.01114.39
5.6.340.0060.00614.00
5.6.330.0090.00614.50
5.6.320.0040.01214.25
5.6.310.0000.01414.08
5.6.300.0030.01214.55
5.6.290.0070.00414.65
5.6.280.0020.04417.68
5.6.270.0090.00314.58
5.6.260.0000.01114.11
5.6.250.0030.00614.49
5.6.240.0030.01314.05
5.6.230.0070.04317.43
5.6.220.0070.03217.46
5.6.210.0070.04617.42
5.6.200.0080.04517.67
5.6.190.0060.02617.69
5.6.180.0100.04717.71
5.6.170.0080.02817.57
5.6.160.0090.04517.71
5.6.150.0100.04317.66
5.6.140.0070.04817.64
5.6.130.0030.03017.79
5.6.120.0120.03717.78
5.6.110.0090.04417.68
5.6.100.0150.04017.59
5.6.90.0100.04017.71
5.6.80.0120.02717.19
5.6.70.0070.04417.37
5.6.60.0100.04117.34
5.6.50.0110.03717.37
5.6.40.0150.03517.28
5.6.30.0060.03017.47
5.6.20.0100.03917.35
5.6.10.0090.04417.36
5.6.00.0020.03717.23
5.5.380.0030.00711.08
5.5.370.0060.04115.79
5.5.360.0110.04015.75
5.5.350.0150.03815.66
5.5.340.0080.03516.07
5.5.330.0120.02516.06
5.5.320.0080.04015.85
5.5.310.0030.03216.05
5.5.300.0040.02716.13
5.5.290.0060.02915.89
5.5.280.0100.03616.05
5.5.270.0050.04316.19
5.5.260.0050.03315.97
5.5.250.0060.04615.90
5.5.240.0080.04015.70
5.5.230.0040.03415.72
5.5.220.0040.03815.61
5.5.210.0140.03515.77
5.5.200.0050.04215.68
5.5.190.0090.04115.65
5.5.180.0030.03815.69
5.5.170.0000.01411.17
5.5.160.0070.04215.57
5.5.150.0070.04015.69
5.5.140.0080.03815.54
5.5.130.0070.04515.74
5.5.120.0050.03015.77
5.5.110.0080.04515.62
5.5.100.0130.04015.56
5.5.90.0110.02315.70
5.5.80.0110.03815.68
5.5.70.0080.03815.58
5.5.60.0090.03715.77
5.5.50.0080.03815.55
5.5.40.0080.04015.74
5.5.30.0120.03315.55
5.5.20.0070.02715.75
5.5.10.0080.04015.59
5.5.00.0040.04515.49
5.4.450.0100.03715.40
5.4.440.0040.03415.30
5.4.430.0080.03715.29
5.4.420.0060.04415.17
5.4.410.0110.04115.13
5.4.400.0080.03715.09
5.4.390.0090.04015.01
5.4.380.0040.04215.05
5.4.370.0030.04115.29
5.4.360.0030.04215.25
5.4.350.0070.03815.18
5.4.340.0060.04115.19
5.4.330.0060.00010.99
5.4.320.0080.04014.96
5.4.310.0080.04115.03
5.4.300.0080.03714.87
5.4.290.0110.03514.87
5.4.280.0050.04315.08
5.4.270.0090.03915.13
5.4.260.0080.04014.84
5.4.250.0050.04415.32
5.4.240.0050.04114.94
5.4.230.0030.02915.12
5.4.220.0070.04115.17
5.4.210.0120.03715.06
5.4.200.0070.03015.04
5.4.190.0050.03815.19
5.4.180.0050.04214.93
5.4.170.0030.03015.04
5.4.160.0070.03815.00
5.4.150.0120.03915.07
5.4.140.0050.03213.69
5.4.130.0080.01513.76
5.4.120.0050.02313.49
5.4.110.0060.03613.83
5.4.100.0090.03913.68
5.4.90.0100.03513.82
5.4.80.0060.04013.87
5.4.70.0070.03813.72
5.4.60.0050.02913.71
5.4.50.0120.03413.76
5.4.40.0070.04113.91
5.4.30.0080.03613.68
5.4.20.0090.03613.67
5.4.10.0020.04413.63
5.4.00.0060.02513.51
5.3.290.0090.03212.55
5.3.280.0030.04212.63
5.3.270.0050.04012.74
5.3.260.0070.04012.61
5.3.250.0080.04012.48
5.3.240.0030.02912.59
5.3.230.0100.01812.66
5.3.220.0020.03912.61
5.3.210.0100.04012.45
5.3.200.0030.02812.44
5.3.190.0050.02812.50
5.3.180.0040.03712.72
5.3.170.0070.03712.70
5.3.160.0000.03012.59
5.3.150.0020.03012.64
5.3.140.0030.03312.50
5.3.130.0100.04012.63
5.3.120.0070.04212.54
5.3.110.0140.03312.54
5.3.100.0060.04112.36
5.3.90.0070.04012.31
5.3.80.0070.02812.20
5.3.70.0070.04112.25
5.3.60.0030.04112.29
5.3.50.0100.03612.09
5.3.40.0090.03612.23
5.3.30.0030.03512.28
5.3.20.0030.04112.01
5.3.10.0080.03811.94
5.3.00.0050.03911.91
5.2.170.0030.03710.70
5.2.160.0090.02910.68
5.2.150.0030.03710.72
5.2.140.0050.03410.67
5.2.130.0070.03510.62
5.2.120.0070.02310.67
5.2.110.0030.03410.72
5.2.100.0090.02810.65
5.2.90.0050.03010.62
5.2.80.0020.03310.62
5.2.70.0070.03210.62
5.2.60.0070.03210.62
5.2.50.0020.03510.62
5.2.40.0050.03510.64
5.2.30.0080.03010.62
5.2.20.0050.03210.62
5.2.10.0030.03310.62
5.2.00.0090.02710.62
5.1.60.0020.03010.62
5.1.50.0030.02810.62
5.1.40.0020.03010.62
5.1.30.0000.02210.62
5.1.20.0100.02510.62
5.1.10.0050.03010.62
5.1.00.0100.02710.62
5.0.50.0050.01610.62
5.0.40.0030.02310.62
5.0.30.0050.03410.62
5.0.20.0050.01710.62
5.0.10.0060.02310.62
5.0.00.0040.03210.62
4.4.90.0000.02310.62
4.4.80.0040.01710.62
4.4.70.0010.01610.62
4.4.60.0070.01610.62
4.4.50.0000.01910.62
4.4.40.0020.02910.62
4.4.30.0000.02110.62
4.4.20.0060.01810.62
4.4.10.0030.01710.62
4.4.00.0030.01610.62
4.3.110.0040.02010.62
4.3.100.0020.01910.62
4.3.90.0050.01810.62
4.3.80.0020.02010.62
4.3.70.0040.01910.62
4.3.60.0050.01210.62
4.3.50.0050.01610.62
4.3.40.0040.02210.62
4.3.30.0020.02210.62
4.3.20.0050.01710.62
4.3.10.0030.01310.62
4.3.00.0010.02010.62

preferences:
46.68 ms | 400 KiB | 5 Q