3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MapIterator implements IteratorAgrigate { 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.0140.00318.40
8.3.50.0130.00521.14
8.3.40.0070.00718.84
8.3.30.0130.00020.07
8.3.20.0030.00518.72
8.3.10.0040.00420.83
8.3.00.0040.00422.52
8.2.180.0130.00316.63
8.2.170.0090.00922.96
8.2.160.0100.00320.39
8.2.150.0030.00524.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0000.00720.97
8.2.110.0090.00022.13
8.2.100.0110.00017.84
8.2.90.0020.00519.05
8.2.80.0000.00819.39
8.2.70.0060.00317.63
8.2.60.0000.00817.93
8.2.50.0000.00818.07
8.2.40.0060.00318.09
8.2.30.0050.00219.41
8.2.20.0040.00417.72
8.2.10.0000.00717.77
8.2.00.0080.00017.75
8.1.280.0080.00825.92
8.1.270.0080.00023.99
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0040.00720.82
8.1.230.0120.00021.10
8.1.220.0080.00018.77
8.1.210.0040.00418.97
8.1.200.0030.00617.35
8.1.190.0030.00617.41
8.1.180.0050.00318.10
8.1.170.0000.00818.57
8.1.160.0040.00418.89
8.1.150.0080.00018.63
8.1.140.0050.00217.27
8.1.130.0030.00317.68
8.1.120.0000.00717.33
8.1.110.0000.00917.38
8.1.100.0000.00717.31
8.1.90.0000.00717.31
8.1.80.0000.00717.47
8.1.70.0000.00717.44
8.1.60.0040.00417.59
8.1.50.0000.00817.39
8.1.40.0040.00417.47
8.1.30.0080.00017.50
8.1.20.0040.00417.65
8.1.10.0040.00417.55
8.1.00.0000.00717.40
8.0.300.0040.00419.98
8.0.290.0020.00517.18
8.0.280.0000.00718.53
8.0.270.0030.00317.33
8.0.260.0060.00316.81
8.0.250.0030.00316.94
8.0.240.0000.00817.06
8.0.230.0040.00416.93
8.0.220.0060.00016.84
8.0.210.0070.00016.88
8.0.200.0060.00017.11
8.0.190.0080.00017.10
8.0.180.0000.00716.98
8.0.170.0000.00816.89
8.0.160.0070.00017.04
8.0.150.0000.00716.83
8.0.140.0040.00416.87
8.0.130.0030.00313.40
8.0.120.0060.00316.97
8.0.110.0000.00716.89
8.0.100.0040.00416.93
8.0.90.0020.00517.09
8.0.80.0060.00916.95
8.0.70.0000.00716.77
8.0.60.0050.00216.87
8.0.50.0000.00716.99
8.0.30.0120.01117.05
8.0.20.0110.00717.40
8.0.10.0000.00817.05
8.0.00.0090.01316.74
7.4.330.0050.00016.83
7.4.320.0030.00316.55
7.4.300.0060.00016.55
7.4.290.0030.00316.41
7.4.280.0000.00716.51
7.4.270.0060.00016.45
7.4.260.0050.00013.30
7.4.250.0000.00816.32
7.4.240.0030.00516.45
7.4.230.0030.00316.36
7.4.220.0090.00916.42
7.4.210.0090.00616.59
7.4.200.0000.00616.58
7.4.190.0000.00616.33
7.4.160.0090.00916.65
7.4.150.0140.00317.40
7.4.140.0110.00717.86
7.4.130.0130.00816.58
7.4.120.0050.01216.41
7.4.110.0040.01316.37
7.4.100.0090.00616.50
7.4.90.0150.00616.61
7.4.80.0070.01019.39
7.4.70.0110.01216.52
7.4.60.0030.01716.54
7.4.50.0030.00616.40
7.4.40.0090.00622.77
7.4.30.0150.00616.45
7.4.10.0080.00914.78
7.4.00.0090.00914.90
7.3.330.0060.00013.12
7.3.320.0050.00013.12
7.3.310.0000.00816.24
7.3.300.0030.00316.32
7.3.290.0070.00716.22
7.3.280.0100.00916.24
7.3.270.0100.00717.40
7.3.260.0080.01018.24
7.3.250.0070.01016.33
7.3.240.0090.00916.37
7.3.230.0100.00616.39
7.3.210.0120.00916.28
7.3.200.0080.01219.39
7.3.190.0110.01116.46
7.3.180.0100.00616.56
7.3.170.0110.00516.29
7.3.160.0160.00016.39
7.3.130.0090.00914.78
7.3.120.0080.00814.83
7.3.110.0040.01214.75
7.3.100.0070.00914.74
7.3.90.0070.00714.81
7.3.80.0080.00514.77
7.3.70.0030.01214.86
7.3.60.0060.00714.67
7.3.50.0000.01214.70
7.3.40.0070.00414.62
7.3.30.0060.00914.67
7.3.20.0090.00716.51
7.3.10.0060.00716.55
7.3.00.0080.00716.53
7.2.330.0070.01016.27
7.2.320.0090.00916.46
7.2.310.0140.00916.62
7.2.300.0130.00316.54
7.2.290.0100.01016.40
7.2.260.0110.00614.80
7.2.250.0100.00814.99
7.2.240.0030.01314.68
7.2.230.0040.01314.99
7.2.220.0100.00514.75
7.2.210.0040.01014.87
7.2.200.0090.00715.00
7.2.190.0060.00814.76
7.2.180.0060.00614.83
7.2.170.0070.00514.78
7.2.160.0070.00614.86
7.2.150.0060.01116.86
7.2.140.0050.01016.70
7.2.130.0060.00916.63
7.2.120.0070.00716.66
7.2.110.0060.00816.65
7.2.100.0040.00916.62
7.2.90.0040.01016.63
7.2.80.0070.00916.69
7.2.70.0060.00916.69
7.2.60.0070.00716.78
7.2.50.0050.00816.67
7.2.40.0030.01116.76
7.2.30.0030.01016.64
7.2.20.0070.00416.72
7.2.10.0030.01016.69
7.2.00.0080.00917.26
7.1.330.0030.01115.61
7.1.320.0070.01015.68
7.1.310.0090.00515.67
7.1.300.0040.00915.51
7.1.290.0050.00815.56
7.1.280.0040.01115.64
7.1.270.0090.00415.69
7.1.260.0020.01015.64
7.1.250.0050.00715.59
7.1.240.0070.00715.66
7.1.230.0050.00715.54
7.1.220.0090.00515.53
7.1.210.0000.01315.67
7.1.200.0080.00415.65
7.1.190.0060.00715.61
7.1.180.0050.00915.56
7.1.170.0060.00515.58
7.1.160.0050.00815.54
7.1.150.0060.00615.64
7.1.140.0050.00815.49
7.1.130.0030.00815.60
7.1.120.0050.00915.71
7.1.110.0070.00715.68
7.1.100.0050.00616.25
7.1.90.0050.00715.62
7.1.80.0080.00715.65
7.1.70.0080.00615.94
7.1.60.0050.01016.52
7.1.50.0080.00815.89
7.1.40.0040.01015.72
7.1.30.0050.01015.70
7.1.20.0060.00515.72
7.1.10.0080.00615.54
7.1.00.0070.01917.20
7.0.330.0080.00615.14
7.0.320.0070.00715.12
7.0.310.0030.00915.20
7.0.300.0060.00715.23
7.0.290.0100.00215.27
7.0.280.0060.00815.27
7.0.270.0010.01215.35
7.0.260.0030.01115.06
7.0.250.0020.01015.25
7.0.240.0050.00715.26
7.0.230.0090.00215.29
7.0.220.0050.00915.32
7.0.210.0080.00615.25
7.0.200.0030.00815.60
7.0.190.0080.00515.19
7.0.180.0050.00715.18
7.0.170.0070.00715.30
7.0.160.0070.00715.35
7.0.150.0030.00815.21
7.0.140.0050.02416.99
7.0.130.0060.00715.30
7.0.120.0070.00615.28
7.0.110.0070.00815.33
7.0.100.0030.00815.34
7.0.90.0030.00615.44
7.0.80.0060.00715.22
7.0.70.0060.00815.14
7.0.60.0070.02416.46
7.0.50.0060.02516.00
7.0.40.0070.02114.99
7.0.30.0110.02115.10
7.0.20.0120.02514.96
7.0.10.0050.02714.99
7.0.00.0040.01815.01
5.6.400.0030.00914.47
5.6.390.0030.00914.02
5.6.380.0050.00914.14
5.6.370.0060.00914.39
5.6.360.0070.00514.01
5.6.350.0070.00513.97
5.6.340.0050.00814.20
5.6.330.0030.01014.25
5.6.320.0040.01114.04
5.6.310.0050.00814.30
5.6.300.0050.01014.33
5.6.290.0020.01214.19
5.6.280.0080.00814.01
5.6.270.0060.00914.18
5.6.260.0070.00814.02
5.6.250.0050.00614.30
5.6.240.0050.00914.22
5.6.230.0050.00814.08
5.6.220.0040.01114.13
5.6.210.0090.02215.70
5.6.200.0090.02215.09
5.6.190.0050.01615.64
5.6.180.0120.02215.59
5.6.170.0090.02515.76
5.6.160.0050.01715.67
5.6.150.0070.02415.13
5.6.140.0020.02315.22
5.6.130.0060.02715.29
5.6.120.0060.02115.85
5.6.110.0060.02015.79
5.6.100.0070.01515.92
5.6.90.0080.02515.95
5.6.80.0030.02715.58
5.6.70.1190.01515.71
5.6.60.0040.00714.08
5.6.50.0050.00714.15
5.6.40.0060.00713.97
5.6.30.0050.01114.14
5.6.20.0060.00614.18
5.6.10.0030.01014.15
5.6.00.0060.00714.05
5.5.380.0070.00714.11
5.5.370.0030.00814.10
5.5.360.0060.00814.22
5.5.350.0090.02615.67
5.5.340.0040.02115.05
5.5.330.0040.01815.55
5.5.320.0030.02115.54
5.5.310.0070.01715.81
5.5.300.0040.02014.92
5.5.290.0040.02415.03
5.5.280.0070.02415.78
5.5.270.0050.01815.73
5.5.260.0020.03115.75
5.5.250.0070.01315.75
5.5.240.0120.02315.53
5.5.230.0060.00613.98
5.5.220.0050.00813.95
5.5.210.0070.00614.02
5.5.200.0090.00914.04
5.5.190.0090.00514.02
5.5.180.0070.00314.01
5.5.170.0040.00814.02
5.5.160.0040.00813.82
5.5.150.0040.00713.86
5.5.140.0040.00813.92
5.5.130.0060.00814.13
5.5.120.0060.00914.14
5.5.110.0030.00913.87
5.5.100.0060.00714.04
5.5.90.0060.01014.15
5.5.80.0070.00714.02
5.5.70.0020.01013.79
5.5.60.0070.00713.94
5.5.50.0060.00813.79
5.5.40.0060.00714.02
5.5.30.0080.00713.90
5.5.20.0060.00614.02
5.5.10.0070.00613.99
5.5.00.0090.00414.01
5.4.450.0670.01513.47
5.4.440.0870.01413.49
5.4.430.0900.01513.48
5.4.420.1130.01513.44
5.4.410.0940.01513.35
5.4.400.0900.01413.45
5.4.390.0830.01313.35
5.4.380.0770.01413.38
5.4.370.1070.01213.37
5.4.360.0880.01813.28
5.4.350.0770.01713.32
5.4.340.0790.01513.45
5.4.330.0030.00611.49
5.4.320.0880.01313.46
5.4.310.0900.01513.37
5.4.300.0870.01113.39
5.4.290.0870.01213.37
5.4.280.0820.01813.35
5.4.270.1070.01713.44
5.4.260.0890.01413.39
5.4.250.0870.01613.38
5.4.240.0910.01413.39
5.4.230.0890.01213.33
5.4.220.0880.01213.37
5.4.210.0880.01513.39
5.4.200.0900.01313.41
5.4.190.0870.01613.32
5.4.180.0890.01113.44
5.4.170.0830.01513.30
5.4.160.0850.01413.32
5.4.150.0870.01513.33
5.4.140.0860.01512.72
5.4.130.0820.01512.67
5.4.120.0880.01312.79
5.4.110.1080.01412.74
5.4.100.0940.01312.74
5.4.90.0850.01812.74
5.4.80.0870.01212.77
5.4.70.0840.01312.72
5.4.60.0880.01012.80
5.4.50.0820.01312.77
5.4.40.0840.01212.69
5.4.30.0810.01512.78
5.4.20.0820.01312.72
5.4.10.0850.01212.72
5.4.00.0800.01412.61
5.3.290.0900.01212.18
5.3.280.0790.01312.13
5.3.270.0920.01112.11
5.3.260.0770.01312.14
5.3.250.0780.01412.09
5.3.240.0880.01012.10
5.3.230.0950.01512.13
5.3.220.0900.01312.05
5.3.210.0900.01412.04
5.3.200.0840.01312.10
5.3.190.0880.01512.14
5.3.180.0840.01212.18
5.3.170.0900.01312.17
5.3.160.0910.01012.15
5.3.150.0920.01212.10
5.3.140.0760.01612.06
5.3.130.0880.01812.08
5.3.120.0840.01412.23
5.3.110.0860.01212.05
5.3.100.0850.01211.99
5.3.90.0860.01212.03
5.3.80.0860.01111.94
5.3.70.0890.01012.03
5.3.60.0870.01212.01
5.3.50.0870.01111.98
5.3.40.0780.01211.95
5.3.30.0800.01411.94
5.3.20.0820.01111.92
5.3.10.0870.01411.88
5.3.00.0870.01311.75
5.2.170.2570.02711.23
5.2.160.2930.02711.07
5.2.150.3200.03311.08
5.2.140.2770.02711.16
5.2.130.2570.03311.02
5.2.120.2830.03011.02
5.2.110.2830.02011.11
5.2.100.3170.03011.02
5.2.90.2930.02711.02
5.2.80.2900.03011.33
5.2.70.2900.02711.03
5.2.60.2970.02311.11
5.2.50.2900.03010.94
5.2.40.2330.03010.98
5.2.30.2170.03010.89
5.2.20.2070.03310.97
5.2.10.2370.03010.78
5.2.00.2970.02710.73
5.1.60.2370.02010.13
5.1.50.2170.02310.06
5.1.40.2130.0239.99
5.1.30.2370.02710.32
5.1.20.2470.02010.28
5.1.10.2100.02710.06
5.1.00.2330.0279.97
5.0.50.1270.0238.49
5.0.40.1400.0238.47
5.0.30.1270.0308.16
5.0.20.1070.0208.29
5.0.10.1300.0178.11
5.0.00.0100.0538.26
4.4.90.1230.0175.84
4.4.80.1330.0175.80
4.4.70.1330.0175.82
4.4.60.1330.0105.89
4.4.50.1300.0135.85
4.4.40.1100.0205.88
4.4.30.1300.0175.85
4.4.20.1270.0175.95
4.4.10.1370.0175.92
4.4.00.1000.0275.88
4.3.110.1230.0175.79
4.3.100.1400.0135.82
4.3.90.1270.0205.79
4.3.80.1270.0275.79
4.3.70.1330.0175.79
4.3.60.1330.0175.79
4.3.50.1270.0205.79
4.3.40.1270.0335.79
4.3.30.0670.0235.79
4.3.20.0630.0205.79
4.3.10.0600.0135.79
4.3.00.0670.0235.79

preferences:
43.87 ms | 400 KiB | 5 Q