3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MapIterator implements Iterator { private $f; private $inner; public function __construct($f, $inner) { $this->f = $f; $this->inner = $inner; } function rewind() { return $this->inner->rewind(); } function current() { return call_user_func($this->f, $this->inner->current()); } function key() { return $this->inner->key(); } function next() { return $this->inner->next(); } function valid() { return $this->inner->valid(); } } function iter_map($f, $iter) { return new MapIterator($f, $iter); } // example: function times_two($x) { return $x * 2; } $source = new ArrayIterator([0, 1, 2, 3, 4, 5, 6]); //var_dump(iterator_to_array(iter_map('times_two', $source))); print_r(iterator_to_array(gen_map('times_two', $source)));

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.00618.19
8.3.50.0080.00821.02
8.3.40.0040.01118.82
8.3.30.0110.00420.20
8.3.20.0040.00418.90
8.3.10.0080.00021.09
8.3.00.0000.00922.43
8.2.180.0100.01016.88
8.2.170.0130.00622.96
8.2.160.0100.00320.34
8.2.150.0040.00424.18
8.2.140.0090.00024.66
8.2.130.0080.00026.16
8.2.120.0040.00421.12
8.2.110.0030.00620.41
8.2.100.0000.01217.87
8.2.90.0080.00019.22
8.2.80.0060.00317.97
8.2.70.0060.00617.48
8.2.60.0040.00717.93
8.2.50.0000.00818.07
8.2.40.0050.00318.22
8.2.30.0070.00019.34
8.2.20.0000.00717.65
8.2.10.0040.00417.68
8.2.00.0000.00717.82
8.1.280.0040.01125.92
8.1.270.0080.00023.99
8.1.260.0070.00026.35
8.1.250.0080.00028.09
8.1.240.0070.00319.13
8.1.230.0000.01120.85
8.1.220.0050.00318.77
8.1.210.0000.00818.85
8.1.200.0090.00017.35
8.1.190.0040.00417.53
8.1.180.0040.00418.10
8.1.170.0060.00320.50
8.1.160.0040.00418.97
8.1.150.0070.00018.57
8.1.140.0050.00217.53
8.1.130.0000.00717.90
8.1.120.0070.00017.46
8.1.110.0000.00917.45
8.1.100.0000.00817.46
8.1.90.0040.00417.48
8.1.80.0070.00017.53
8.1.70.0040.00417.40
8.1.60.0030.00717.61
8.1.50.0040.00417.45
8.1.40.0000.00817.52
8.1.30.0040.00417.55
8.1.20.0040.00417.53
8.1.10.0000.00817.61
8.1.00.0000.00817.42
8.0.300.0080.00019.86
8.0.290.0070.00017.05
8.0.280.0070.00018.38
8.0.270.0000.00717.36
8.0.260.0060.00316.91
8.0.250.0070.00017.08
8.0.240.0040.00416.91
8.0.230.0030.00717.10
8.0.220.0030.00317.00
8.0.210.0030.00316.98
8.0.200.0030.00317.02
8.0.190.0040.00416.93
8.0.180.0030.00616.95
8.0.170.0000.00816.99
8.0.160.0030.00317.07
8.0.150.0040.00416.97
8.0.140.0020.00516.96
8.0.130.0030.00313.38
8.0.120.0040.00416.96
8.0.110.0000.00716.95
8.0.100.0040.00416.85
8.0.90.0000.00717.03
8.0.80.0070.00817.03
8.0.70.0000.00717.05
8.0.60.0030.00517.04
8.0.50.0050.00317.00
8.0.30.0100.01017.08
8.0.20.0230.01717.40
8.0.10.0040.00417.04
8.0.00.0130.00616.81
7.4.330.0050.00016.70
7.4.320.0030.00316.54
7.4.300.0030.00316.52
7.4.290.0000.00716.39
7.4.280.0030.00316.55
7.4.270.0030.00316.61
7.4.260.0030.00313.34
7.4.250.0050.00316.40
7.4.240.0050.00216.57
7.4.230.0000.00716.74
7.4.220.0030.01616.55
7.4.210.0050.00916.60
7.4.200.0000.00816.66
7.4.190.0070.00016.73
7.4.160.0080.00816.63
7.4.150.0090.00917.40
7.4.140.0110.00817.86
7.4.130.0110.00616.55
7.4.120.0110.00716.60
7.4.110.0040.01216.59
7.4.100.0140.00316.52
7.4.90.0190.00016.60
7.4.80.0120.00619.39
7.4.70.0100.00716.60
7.4.60.0030.01316.56
7.4.50.0020.00216.64
7.4.40.0030.01322.77
7.4.30.0030.01416.23
7.4.10.0060.01315.23
7.4.00.0110.00615.13
7.3.330.0000.00513.28
7.3.320.0030.00313.12
7.3.310.0030.00316.35
7.3.300.0050.00316.36
7.3.290.0040.01016.31
7.3.280.0080.01016.31
7.3.270.0110.00617.40
7.3.260.0130.00618.24
7.3.250.0140.00516.46
7.3.240.0090.00916.57
7.3.230.0100.00716.43
7.3.210.0150.00416.38
7.3.200.0140.00819.39
7.3.190.0100.00616.54
7.3.180.0100.00716.46
7.3.170.0100.00916.56
7.3.160.0090.00616.45
7.3.130.0100.00714.73
7.3.120.0090.00714.78
7.3.110.0000.01414.76
7.3.100.0060.00814.89
7.3.90.0030.01014.65
7.3.80.0000.01114.75
7.3.70.0040.01214.80
7.3.60.0020.01414.68
7.3.50.0050.00714.82
7.3.40.0100.00314.63
7.3.30.0070.00414.77
7.3.20.0060.00616.65
7.3.10.0050.01116.42
7.3.00.0090.00316.65
7.2.330.0100.01016.37
7.2.320.0090.00916.59
7.2.310.0120.01216.39
7.2.300.0100.00616.73
7.2.290.0130.01016.47
7.2.260.0080.00815.02
7.2.250.0090.01014.88
7.2.240.0110.00514.81
7.2.230.0060.00814.88
7.2.220.0110.00415.05
7.2.210.0070.00915.07
7.2.200.0040.01015.04
7.2.190.0080.00714.96
7.2.180.0030.01015.02
7.2.170.0020.01514.85
7.2.160.0090.00714.97
7.2.150.0050.00816.89
7.2.140.0070.01016.83
7.2.130.0030.01016.76
7.2.120.0060.00916.82
7.2.110.0070.01016.79
7.2.100.0080.00616.94
7.2.90.0030.01016.72
7.2.80.0090.00616.80
7.2.70.0080.00316.88
7.2.60.0070.01016.79
7.2.50.0070.00816.76
7.2.40.0070.00716.77
7.2.30.0020.01216.67
7.2.20.0060.01016.82
7.2.10.0050.00616.96
7.2.00.0070.00917.80
7.1.330.0020.01215.51
7.1.320.0050.00615.67
7.1.310.0040.00915.77
7.1.300.0050.00915.72
7.1.290.0050.00915.73
7.1.280.0050.00815.43
7.1.270.0030.00815.57
7.1.260.0020.01115.62
7.1.250.0030.00815.78
7.1.240.0030.00915.64
7.1.230.0030.00715.59
7.1.220.0090.00615.71
7.1.210.0000.01515.80
7.1.200.0030.00815.56
7.1.190.0000.01315.65
7.1.180.0040.00715.79
7.1.170.0100.00315.42
7.1.160.0070.01015.74
7.1.150.0000.00915.64
7.1.140.0040.00715.76
7.1.130.0070.00315.73
7.1.120.0080.00615.55
7.1.110.0000.01415.70
7.1.100.0070.00516.83
7.1.90.0000.00915.59
7.1.80.0030.00915.66
7.1.70.0070.00516.28
7.1.60.0080.01017.28
7.1.50.0050.01316.16
7.1.40.0080.00315.49
7.1.30.0090.00615.72
7.1.20.0090.00615.75
7.1.10.0070.00715.79
7.1.00.0080.04318.90
7.0.330.0000.01115.22
7.0.320.0070.00715.39
7.0.310.0030.00915.49
7.0.300.0030.00715.28
7.0.290.0070.00415.45
7.0.280.0100.00315.33
7.0.270.0040.00715.00
7.0.260.0070.00415.37
7.0.250.0030.00615.34
7.0.240.0080.00415.26
7.0.230.0000.01015.53
7.0.220.0060.00615.61
7.0.210.0070.00715.20
7.0.200.0070.00416.07
7.0.190.0090.00315.26
7.0.180.0040.00815.45
7.0.170.0050.00815.39
7.0.160.0060.00615.38
7.0.150.0070.01015.44
7.0.140.0050.04118.68
7.0.130.0040.00815.46
7.0.120.0110.00415.20
7.0.110.0140.00015.44
7.0.100.0050.03717.56
7.0.90.0030.04417.69
7.0.80.0080.03317.48
7.0.70.0070.04717.68
7.0.60.0160.04117.70
7.0.50.0140.02717.97
7.0.40.0100.03616.82
7.0.30.0070.02316.83
7.0.20.0050.03016.84
7.0.10.0090.04416.69
7.0.00.0100.04416.77
5.6.400.0070.00714.23
5.6.390.0040.00714.13
5.6.380.0040.01214.28
5.6.370.0100.00314.20
5.6.360.0030.01014.39
5.6.350.0090.00614.23
5.6.340.0070.00414.25
5.6.330.0000.01314.29
5.6.320.0090.00014.64
5.6.310.0060.01014.36
5.6.300.0070.00714.27
5.6.290.0120.00614.46
5.6.280.0050.04117.68
5.6.270.0030.01214.21
5.6.260.0120.00314.21
5.6.250.0080.04117.38
5.6.240.0130.03517.58
5.6.230.0050.03317.49
5.6.220.0050.02417.45
5.6.210.0070.02617.46
5.6.200.0100.03317.66
5.6.190.0060.02817.78
5.6.180.0060.03617.80
5.6.170.0100.04617.62
5.6.160.0070.04117.68
5.6.150.0050.03617.62
5.6.140.0050.04317.70
5.6.130.0090.04217.80
5.6.120.0070.02717.62
5.6.110.0050.04917.57
5.6.100.0070.03817.52
5.6.90.0070.02617.67
5.6.80.0100.03817.44
5.6.70.0070.04217.45
5.6.60.0140.03517.33
5.6.50.0030.03217.22
5.6.40.0090.02717.27
5.6.30.0040.02417.29
5.6.20.0050.04317.45
5.6.10.0030.03017.25
5.6.00.0100.04017.41
5.5.380.0090.02717.43
5.5.370.0070.03317.53
5.5.360.0070.03517.42
5.5.350.0050.02517.27
5.5.340.0070.02217.48
5.5.330.0070.04217.60
5.5.320.0080.02517.59
5.5.310.0110.04617.44
5.5.300.0070.03017.61
5.5.290.0070.04917.60
5.5.280.0050.03017.68
5.5.270.0020.04917.54
5.5.260.0030.03717.66
5.5.250.0080.04017.32
5.5.240.0050.03317.13
5.5.230.0080.03317.13
5.5.220.0060.02917.25
5.5.210.0050.02517.27
5.5.200.0120.03717.25
5.5.190.0040.03417.03
5.5.180.0090.03017.23
5.5.170.0070.00614.01
5.5.160.0060.02517.22
5.5.150.0070.04217.01
5.5.140.0100.03317.03
5.5.130.0110.03717.16
5.5.120.0070.03217.21
5.5.110.0050.02517.16
5.5.100.0080.02517.15
5.5.90.0070.02217.12
5.5.80.0110.03817.23
5.5.70.0080.03717.22
5.5.60.0070.04417.12
5.5.50.0060.04117.18
5.5.40.0100.04216.93
5.5.30.0030.04016.96
5.5.20.0080.03717.11
5.5.10.0020.04317.16
5.5.00.0050.03316.99
5.4.450.0050.02616.01
5.4.440.0020.02816.00
5.4.430.0050.03315.96
5.4.420.0020.02915.91
5.4.410.0090.03615.89
5.4.400.0120.03115.81
5.4.390.0100.04015.78
5.4.380.0030.03715.77
5.4.370.0060.02615.75
5.4.360.0050.03615.86
5.4.350.0020.02715.80
5.4.340.0070.02715.84
5.4.330.0040.00712.46
5.4.320.0080.04015.80
5.4.310.0030.04115.75
5.4.300.0050.02015.81
5.4.290.0050.04115.84
5.4.280.0030.03115.78
5.4.270.0030.03515.67
5.4.260.0050.04515.84
5.4.250.0020.02515.75
5.4.240.0050.04015.75
5.4.230.0100.03515.83
5.4.220.0060.02315.84
5.4.210.0090.02715.65
5.4.200.0020.02715.79
5.4.190.0040.04715.74
5.4.180.0050.04315.82
5.4.170.0000.02715.82
5.4.160.0020.02715.67
5.4.150.0050.03815.81
5.4.140.0060.03314.46
5.4.130.0090.01714.38
5.4.120.0070.01714.47
5.4.110.0050.03914.48
5.4.100.0030.04214.48
5.4.90.0050.04214.43
5.4.80.0050.02914.42
5.4.70.0050.03514.49
5.4.60.0100.03714.45
5.4.50.0110.02014.43
5.4.40.0020.02714.49
5.4.30.0030.02814.41
5.4.20.0080.03214.43
5.4.10.0100.03314.45
5.4.00.0020.04214.20
5.3.290.0070.02513.56
5.3.280.0000.03113.60
5.3.270.0100.03313.53
5.3.260.0040.04213.52
5.3.250.0020.03613.59
5.3.240.0080.03313.50
5.3.230.0070.03313.54
5.3.220.0050.02013.57
5.3.210.0030.04213.59
5.3.200.0050.03313.58
5.3.190.0080.03613.51
5.3.180.0020.04213.54
5.3.170.0020.02513.57
5.3.160.0080.03613.51
5.3.150.0030.03013.50
5.3.140.0030.02213.58
5.3.130.0030.04313.49
5.3.120.0070.02413.56
5.3.110.0050.02513.50
5.3.100.0050.04013.25
5.3.90.0030.04313.28
5.3.80.0060.03613.31
5.3.70.0050.03813.28
5.3.60.0110.03013.24
5.3.50.0080.03513.16
5.3.40.0030.02513.20
5.3.30.0050.01813.25
5.3.20.0070.01713.05
5.3.10.0070.03013.03
5.3.00.0060.01813.06
5.2.170.0030.06311.25
5.2.160.0030.03011.16
5.2.150.0030.03011.25
5.2.140.0030.03711.14
5.2.130.0030.03011.16
5.2.120.0000.03311.22
5.2.110.0100.02311.14
5.2.100.0000.03311.06
5.2.90.0030.02711.10
5.2.80.0000.03311.16
5.2.70.0030.03011.17
5.2.60.0030.02711.00
5.2.50.0070.03011.03
5.2.40.0000.03011.06
5.2.30.0000.02711.09
5.2.20.0070.02011.11
5.2.10.0000.03010.73
5.2.00.0000.03010.79
5.1.60.0000.02710.09
5.1.50.0100.01710.04
5.1.40.0030.02310.00
5.1.30.0070.02310.29
5.1.20.0030.02310.43
5.1.10.0030.0239.98
5.1.00.0030.0239.92
5.0.50.0000.0208.64
5.0.40.0000.0178.51
5.0.30.0030.0308.12
5.0.20.0000.0208.28
5.0.10.0030.0178.27
5.0.00.0100.0238.27
4.4.90.0000.0178.12
4.4.80.0030.0138.12
4.4.70.0030.0138.12
4.4.60.0070.0108.12
4.4.50.0030.0138.12
4.4.40.0000.0238.12
4.4.30.0000.0178.12
4.4.20.0000.0138.12
4.4.10.0000.0138.12
4.4.00.0000.0208.12
4.3.110.0030.0138.12
4.3.100.0000.0178.12
4.3.90.0030.0138.12
4.3.80.0000.0238.12
4.3.70.0030.0138.12
4.3.60.0070.0078.12
4.3.50.0000.0138.12
4.3.40.0000.0338.12
4.3.30.0070.0108.12
4.3.20.0000.0178.12
4.3.10.0070.0108.12
4.3.00.0000.0178.12

preferences:
45.79 ms | 401 KiB | 5 Q