3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MapIterator implements IteratorAgregate { private $f; private $inner; public function __construct($f, $inner) { $this->f = $f; $this->inner = $inner; } function current() { return call_user_func($this->f, $this->inner->current()); } function getIterator() { return $this->inner; } } 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]); print_r(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.0070.01018.43
8.3.50.0100.01021.21
8.3.40.0120.00318.59
8.3.30.0080.00520.34
8.3.20.0030.00518.90
8.3.10.0080.00021.15
8.3.00.0050.00322.46
8.2.180.0140.00717.00
8.2.170.0130.00622.96
8.2.160.0140.00020.35
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0050.00220.98
8.2.110.0040.00422.01
8.2.100.0080.00317.84
8.2.90.0000.00819.09
8.2.80.0060.00317.97
8.2.70.0040.00417.50
8.2.60.0030.00517.78
8.2.50.0000.00818.07
8.2.40.0000.00818.09
8.2.30.0040.00419.46
8.2.20.0080.00017.75
8.2.10.0000.00717.77
8.2.00.0030.00517.74
8.1.280.0160.00325.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00422.08
8.1.230.0070.00417.51
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0090.00017.23
8.1.190.0040.00417.40
8.1.180.0000.00818.10
8.1.170.0000.00818.66
8.1.160.0040.00418.89
8.1.150.0040.00418.55
8.1.140.0040.00417.41
8.1.130.0030.00317.65
8.1.120.0040.00417.42
8.1.110.0060.00317.29
8.1.100.0000.00717.34
8.1.90.0050.00317.31
8.1.80.0040.00417.41
8.1.70.0000.00717.40
8.1.60.0040.00417.54
8.1.50.0030.00617.36
8.1.40.0000.00817.38
8.1.30.0040.00417.48
8.1.20.0030.00517.54
8.1.10.0030.00617.42
8.1.00.0000.00817.44
8.0.300.0000.00718.77
8.0.290.0080.00016.63
8.0.280.0070.00018.46
8.0.270.0030.00317.32
8.0.260.0000.00916.95
8.0.250.0000.00716.98
8.0.240.0070.00017.09
8.0.230.0070.00017.04
8.0.220.0030.00316.87
8.0.210.0070.00016.97
8.0.200.0040.00416.91
8.0.190.0040.00417.00
8.0.180.0080.00016.88
8.0.170.0040.00416.92
8.0.160.0000.00717.03
8.0.150.0050.00316.99
8.0.140.0040.00416.93
8.0.130.0030.00313.44
8.0.120.0000.00816.90
8.0.110.0030.00517.00
8.0.100.0000.00716.79
8.0.90.0000.00716.82
8.0.80.0120.00316.96
8.0.70.0000.00716.92
8.0.60.0070.00016.87
8.0.50.0070.00016.93
8.0.30.0060.01417.08
8.0.20.0110.00717.40
8.0.10.0040.00416.87
8.0.00.0120.00916.70
7.4.330.0050.00016.84
7.4.320.0070.00016.56
7.4.300.0000.00616.50
7.4.290.0070.00016.47
7.4.280.0000.00716.54
7.4.270.0000.00716.56
7.4.260.0000.00613.34
7.4.250.0040.00416.32
7.4.240.0050.00216.46
7.4.230.0070.00016.55
7.4.220.0180.00716.63
7.4.210.0070.00916.51
7.4.200.0070.00016.45
7.4.190.0000.00716.59
7.4.160.0160.00616.43
7.4.150.0130.00517.40
7.4.140.0090.00817.86
7.4.130.0030.01716.39
7.4.120.0110.00916.59
7.4.110.0130.00316.49
7.4.100.0150.00416.44
7.4.90.0100.00716.52
7.4.80.0150.00319.39
7.4.70.0080.00916.48
7.4.60.0160.00016.55
7.4.50.0050.00516.51
7.4.40.0030.01622.77
7.4.30.0090.01216.66
7.4.00.0070.01115.05
7.3.330.0000.00513.03
7.3.320.0030.00313.20
7.3.310.0030.00616.24
7.3.300.0040.00416.25
7.3.290.0100.00316.27
7.3.280.0080.00816.21
7.3.270.0100.01317.40
7.3.260.0130.00918.24
7.3.250.0050.01216.48
7.3.240.0130.01016.21
7.3.230.0070.01016.50
7.3.210.0030.01416.37
7.3.200.0070.01419.39
7.3.190.0030.01416.25
7.3.180.0090.00916.47
7.3.170.0030.01216.31
7.3.160.0080.00816.45
7.3.120.0090.00614.65
7.3.00.0180.00316.63
7.2.330.0150.00616.48
7.2.320.0100.01316.31
7.2.310.0190.00616.29
7.2.300.0100.00716.54
7.2.290.0030.01416.64
7.2.130.0150.00616.86
7.2.120.0100.01016.85
7.2.110.0090.00916.37
7.2.100.0120.00616.37
7.2.90.0070.01516.86
7.2.80.0060.01016.60
7.2.70.0110.00316.78
7.2.60.0150.00316.59
7.2.50.0170.00716.70
7.2.40.0030.01016.68
7.2.30.0080.01216.58
7.2.20.0090.00616.61
7.2.10.0090.00016.72
7.2.00.0020.01218.04
7.1.250.0090.00615.64
7.1.240.0090.00415.40
7.1.230.0040.00815.73
7.1.220.0090.00915.44
7.1.210.0060.00915.53
7.1.200.0070.00715.80
7.1.190.0030.01315.48
7.1.180.0040.01115.41
7.1.170.0040.00715.50
7.1.160.0090.00315.71
7.1.150.0070.00715.53
7.1.140.0040.00715.71
7.1.130.0060.00615.65
7.1.120.0100.00315.80
7.1.110.0090.00615.67
7.1.100.0030.01016.82
7.1.90.0000.01315.85
7.1.80.0040.00715.73
7.1.70.0070.00616.27
7.1.60.0080.01017.34
7.1.50.0120.00516.25
7.1.40.0000.01015.62
7.1.30.0040.00815.68
7.1.20.0000.01315.71
7.1.10.0030.00615.72
7.1.00.0050.03319.06
7.0.330.0070.01114.82
7.0.320.0110.00415.12
7.0.310.0120.00615.07
7.0.300.0000.01115.07
7.0.290.0050.00514.91
7.0.280.0030.01315.17
7.0.270.0120.00415.25
7.0.260.0040.01114.89
7.0.250.0090.00314.90
7.0.240.0000.01015.31
7.0.230.0100.00315.25
7.0.220.0030.00915.37
7.0.210.0030.00915.16
7.0.200.0090.00215.92
7.0.190.0060.00615.20
7.0.180.0070.00715.22
7.0.170.0070.00715.36
7.0.160.0100.00015.09
7.0.150.0070.00315.13
7.0.140.0030.03818.56
7.0.130.0000.00815.44
7.0.120.0060.00615.27
7.0.110.0040.00715.09
7.0.100.0070.00315.15
7.0.90.0040.00415.15
7.0.80.0040.00815.23
7.0.70.0080.00414.96
7.0.60.0030.03818.48
7.0.50.0050.02318.80
7.0.40.0020.04516.65
7.0.30.0030.05016.83
7.0.20.0030.04716.66
7.0.10.0070.04316.74
7.0.00.0020.04516.69
5.6.380.0090.00214.21
5.6.370.0090.00614.18
5.6.360.0060.00613.91
5.6.350.0050.00913.86
5.6.340.0030.01013.95
5.6.330.0040.01813.66
5.6.320.0070.01113.75
5.6.310.0040.00814.26
5.6.300.0080.00613.96
5.6.290.0130.00713.68
5.6.280.0060.00613.80
5.6.270.0080.00513.76
5.6.260.0040.01114.07
5.6.250.0110.00313.92
5.6.240.0070.00714.32
5.6.230.0090.00614.20
5.6.220.0000.01413.89
5.6.210.0070.04517.31
5.6.200.0090.04317.37
5.6.190.0070.03217.60
5.6.180.0000.04517.36
5.6.170.0030.04217.46
5.6.160.0070.04217.51
5.6.150.0070.02717.56
5.6.140.0090.02217.50
5.6.130.0010.02617.65
5.6.120.0000.02517.63
5.6.110.0030.02017.49
5.6.100.0030.02217.56
5.6.90.0040.02417.45
5.6.80.0040.02717.15
5.6.70.0000.02617.17
5.6.60.0060.01817.19
5.6.50.0040.02017.29
5.6.40.0030.02017.14
5.6.30.0050.02517.12
5.6.20.0050.01817.21
5.6.10.0050.02017.13
5.6.00.0020.02017.18
5.5.380.0070.00510.90
5.5.370.0000.00910.90
5.5.360.0060.00610.90
5.5.350.0050.04515.67
5.5.340.0080.03715.90
5.5.330.0080.03815.86
5.5.320.0050.04515.85
5.5.310.0020.04715.84
5.5.300.0020.02515.93
5.5.290.0030.02215.89
5.5.280.0030.02015.97
5.5.270.0000.02215.83
5.5.260.0000.02315.78
5.5.250.0050.01615.69
5.5.240.0020.01815.60
5.5.230.0000.02015.49
5.5.220.0030.02015.58
5.5.210.0030.02215.52
5.5.200.0030.01815.53
5.5.190.0050.02815.61
5.5.180.0000.02215.58
5.5.170.0090.00310.90
5.5.160.0030.01715.61
5.5.150.0050.01815.57
5.5.140.0020.02715.49
5.5.130.0070.01515.49
5.5.120.0050.02115.61
5.5.110.0060.01415.52
5.5.100.0030.02315.56
5.5.90.0020.02515.48
5.5.80.0000.04615.59
5.5.70.0080.02215.47
5.5.60.0060.03015.50
5.5.50.0030.04315.49
5.5.40.0070.03815.50
5.5.30.0050.04015.46
5.5.20.0030.03315.51
5.5.10.0080.03815.54
5.5.00.0070.02015.52
5.4.450.0030.02215.13
5.4.440.0030.02315.12
5.4.430.0030.01915.22
5.4.420.0050.02015.12
5.4.410.0040.02015.08
5.4.400.0050.01715.05
5.4.390.0040.02214.90
5.4.380.0030.01814.96
5.4.370.0060.01614.98
5.4.360.0050.01514.97
5.4.350.0020.02114.99
5.4.340.0030.01714.96
5.4.330.0090.00010.90
5.4.320.0030.01814.90
5.4.310.0040.01514.89
5.4.300.0020.02514.98
5.4.290.0000.01815.06
5.4.280.0000.02214.98
5.4.270.0020.02014.98
5.4.260.0060.03015.03
5.4.250.0030.04214.98
5.4.240.0010.04114.95
5.4.230.0050.04014.95
5.4.220.0050.03715.05
5.4.210.0050.03214.98
5.4.200.0070.02714.98
5.4.190.0050.04114.91
5.4.180.0060.02014.95
5.4.170.0070.02515.05
5.4.160.0020.04315.02
5.4.150.0070.03214.94
5.4.140.0070.02513.69
5.4.130.0050.02913.80
5.4.120.0060.02513.65
5.4.110.0040.02713.69
5.4.100.0050.03613.64
5.4.90.0080.03713.67
5.4.80.0010.02613.67
5.4.70.0050.03713.64
5.4.60.0060.02213.62
5.4.50.0040.03713.56
5.4.40.0050.03513.68
5.4.30.0030.04013.67
5.4.20.0050.03113.60
5.4.10.0020.04213.63
5.4.00.0010.02813.43
5.3.290.0000.02012.83
5.3.280.0050.03212.73
5.3.270.0000.04012.74
5.3.260.0040.02512.80
5.3.250.0060.02212.82
5.3.240.0080.03512.80
5.3.230.0050.03812.75
5.3.220.0050.03812.76
5.3.210.0000.03412.77
5.3.200.0030.02612.76
5.3.190.0050.04212.70
5.3.180.0060.03812.74
5.3.170.0020.02212.78
5.3.160.0050.04012.69
5.3.150.0000.03412.76
5.3.140.0030.04312.77
5.3.130.0030.03612.75
5.3.120.0030.03812.77
5.3.110.0040.03012.76
5.3.100.0010.02312.53
5.3.90.0030.02212.49
5.3.80.0040.03512.49
5.3.70.0060.03112.49
5.3.60.0020.02112.46
5.3.50.0070.03812.38
5.3.40.0030.03612.47
5.3.30.0030.02312.42
5.3.20.0040.02212.30
5.3.10.0020.02512.24
5.3.00.0030.03912.25
5.2.170.0030.02811.08
5.2.160.0010.02411.07
5.2.150.0000.03010.97
5.2.140.0020.02011.07
5.2.130.0030.03511.01
5.2.120.0010.02111.03
5.2.110.0010.01610.95
5.2.100.0020.03511.05
5.2.90.0030.02510.93
5.2.80.0010.02511.03
5.2.70.0020.02011.04
5.2.60.0040.03311.00
5.2.50.0030.04110.97
5.2.40.0010.02810.90
5.2.30.0000.02710.99
5.2.20.0030.01810.96
5.2.10.0050.03210.88
5.2.00.0010.03110.81
5.1.60.0000.03110.48
5.1.50.0060.01710.44
5.1.40.0030.02610.38
5.1.30.0000.03110.62
5.1.20.0050.02810.56
5.1.10.0070.02710.52
5.1.00.0020.03010.48
5.0.50.0020.0239.75
5.0.40.0000.0229.75
5.0.30.0020.0389.75
5.0.20.0020.0239.75
5.0.10.0010.0209.75
5.0.00.0050.0309.75
4.4.90.0000.0159.75
4.4.80.0000.0199.75
4.4.70.0020.0139.75
4.4.60.0000.0149.75
4.4.50.0030.0179.75
4.4.40.0000.0289.75
4.4.30.0000.0229.75
4.4.20.0020.0189.75
4.4.10.0010.0209.75
4.4.00.0000.0299.75
4.3.110.0020.0179.75
4.3.100.0000.0209.75
4.3.90.0000.0179.75
4.3.80.0030.0259.75
4.3.70.0000.0199.75
4.3.60.0000.0209.75
4.3.50.0040.0189.75
4.3.40.0000.0299.75
4.3.30.0050.0149.75
4.3.20.0020.0209.75
4.3.10.0030.0209.75
4.3.00.0010.0179.75

preferences:
38.6 ms | 400 KiB | 5 Q