3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TransformingIterator implements \Iterator { /** * @var Iterator */ private $inner; /** * @var callable */ private $valTransformCallback; /** * @var callable */ private $keyTransformCallback; /** * Constructor * * @param Iterator|array $inner * @param callable $valTransformCallback * @param callable $keyTransformCallback * @throws \InvalidArgumentException */ public function __construct($inner, callable $valTransformCallback = null, callable $keyTransformCallback = null) { if ($inner instanceof \Iterator) { $this->inner = $inner; } else if (is_array($inner)) { $this->inner = new ArrayIterator($inner); } else { throw new \InvalidArgumentException('$inner must be an Iterator or an array'); } $this->valTransformCallback = $valTransformCallback; $this->keyTransformCallback = $keyTransformCallback; } public function current() { return $this->valTransformCallback ? call_user_func($this->valTransformCallback, $this->inner->current()) : $this->inner->current(); } public function next() { $this->inner->next(); } public function key() { return $this->valTransformCallback ? call_user_func($this->valTransformCallback, $this->inner->key()) : $this->inner->key(); } public function valid() { return $this->inner->valid(); } public function rewind() { $this->inner->rewind(); } } $it = new TransformingIterator([1,2,3], function ($value) { return $value + 1; }); foreach ($it as $val) { echo $val . "\n"; }

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.4.120.0160.00520.41
8.4.110.0070.01418.99
8.4.100.0120.00917.71
8.4.90.0100.01118.22
8.4.80.0110.00922.41
8.4.70.0120.00817.84
8.4.60.0090.01118.69
8.4.50.0130.00719.73
8.4.40.0130.00719.63
8.4.30.0040.00417.92
8.4.20.0120.00918.01
8.4.10.0090.00317.90
8.3.250.0120.00819.06
8.3.240.0070.00816.45
8.3.230.0130.00616.54
8.3.220.0110.00717.18
8.3.210.0120.00616.79
8.3.200.0050.00516.68
8.3.190.0050.00717.18
8.3.180.0110.00816.85
8.3.170.0000.00718.97
8.3.160.0180.00018.58
8.3.150.0150.00020.66
8.3.140.0030.01618.41
8.3.130.0000.01516.76
8.3.120.0070.01319.00
8.3.110.0040.00420.94
8.3.100.0080.00016.75
8.3.90.0030.00526.77
8.3.80.0060.00316.75
8.3.70.0070.01116.75
8.3.60.0080.00818.36
8.3.50.0170.00221.97
8.3.40.0130.00618.97
8.3.30.0060.00919.25
8.3.20.0030.00620.39
8.3.10.0040.00423.65
8.3.00.0060.00319.51
8.2.290.0150.00720.61
8.2.280.0050.00319.30
8.2.270.0070.01317.16
8.2.260.0040.00420.59
8.2.250.0050.00316.56
8.2.240.0080.00018.75
8.2.230.0030.00622.58
8.2.220.0080.01124.06
8.2.210.0040.00426.77
8.2.200.0030.00618.41
8.2.190.0040.01118.31
8.2.180.0130.00616.38
8.2.170.0030.01222.96
8.2.160.0090.00620.40
8.2.150.0040.00424.18
8.2.140.0030.01724.66
8.2.130.0030.01026.16
8.2.120.0100.00722.21
8.2.110.0060.00322.25
8.2.100.0090.00317.91
8.2.90.0080.00019.23
8.2.80.0060.00317.97
8.2.70.0060.00317.50
8.2.60.0100.00019.66
8.2.50.0080.00018.07
8.2.40.0050.00319.95
8.2.30.0000.00818.20
8.2.20.0000.00817.63
8.2.10.0000.00818.01
8.2.00.0060.00317.75
8.1.330.0070.00416.83
8.1.320.0100.00816.09
8.1.310.0070.01016.93
8.1.300.0060.00317.82
8.1.290.0070.00330.84
8.1.280.0100.01025.92
8.1.270.0070.00323.91
8.1.260.0120.00626.35
8.1.250.0030.00728.09
8.1.240.0030.00624.00
8.1.230.0080.00319.12
8.1.220.0000.00917.76
8.1.210.0000.00818.77
8.1.200.0060.00317.25
8.1.190.0000.00817.38
8.1.180.0060.00318.10
8.1.170.0090.00018.55
8.1.160.0000.00821.91
8.1.150.0000.00718.54
8.1.140.0050.00517.39
8.1.130.0040.00417.85
8.1.120.0000.00717.48
8.1.110.0050.00317.41
8.1.100.0030.00617.48
8.1.90.0070.00017.41
8.1.80.0000.00717.50
8.1.70.0040.00417.34
8.1.60.0060.00317.65
8.1.50.0090.00017.54
8.1.40.0070.00417.55
8.1.30.0060.00317.70
8.1.20.0000.00817.68
8.1.10.0090.00017.55
8.1.00.0000.00817.50
8.0.300.0000.00718.77
8.0.290.0000.00717.18
8.0.280.0030.00318.47
8.0.270.0030.00317.16
8.0.260.0030.00317.27
8.0.250.0030.00516.94
8.0.240.0040.00416.98
8.0.230.0070.00016.93
8.0.220.0040.00416.95
8.0.210.0040.00416.94
8.0.200.0000.00716.88
8.0.190.0080.00016.96
8.0.180.0040.00416.82
8.0.170.0050.00316.84
8.0.160.0000.00817.01
8.0.150.0000.00716.81
8.0.140.0050.00216.84
8.0.130.0060.00013.28
8.0.120.0050.00316.75
8.0.110.0040.00416.96
8.0.100.0070.00016.91
8.0.90.0040.00416.80
8.0.80.0140.00716.89
8.0.70.0070.00016.96
8.0.60.0000.00716.82
8.0.50.0040.00416.93
8.0.30.0060.01317.20
8.0.20.0100.00817.40
8.0.10.0030.00316.93
8.0.00.0090.01016.74
7.4.330.0000.00515.00
7.4.320.0080.00016.46
7.4.300.0070.00016.66
7.4.290.0030.00616.49
7.4.280.0070.00016.52
7.4.270.0000.00716.63
7.4.260.0000.00716.57
7.4.250.0040.00416.44
7.4.240.0000.00716.57
7.4.230.0020.00516.37
7.4.220.0120.00616.48
7.4.210.0040.01516.64
7.4.200.0000.00816.32
7.4.190.0030.00316.66
7.4.160.0130.00316.34
7.4.150.0100.01717.40
7.4.140.0080.00817.86
7.4.130.0140.00416.52
7.4.120.0120.00516.53
7.4.110.0100.00716.46
7.4.100.0120.00616.39
7.4.90.0100.00716.60
7.4.80.0190.00319.39
7.4.70.0030.01316.54
7.4.60.0070.01316.44
7.4.50.0050.00316.66
7.4.40.0100.00716.30
7.4.30.0140.00316.52
7.4.10.0100.00616.28
7.4.00.0060.01215.49
7.3.330.0000.00613.20
7.3.320.0000.00613.39
7.3.310.0030.00316.40
7.3.300.0040.00416.38
7.3.290.0150.00016.38
7.3.280.0080.01016.38
7.3.270.0100.01017.40
7.3.260.0110.00616.38
7.3.250.0100.00716.44
7.3.240.0110.00616.58
7.3.230.0130.00616.59
7.3.210.0110.00616.66
7.3.200.0030.01619.39
7.3.190.0070.01416.37
7.3.180.0110.00716.70
7.3.170.0080.00816.57
7.3.160.0060.00916.68
7.3.130.0030.01616.67
7.3.120.0080.00715.41
7.3.110.0100.00515.61
7.3.100.0040.01315.56
7.3.90.0070.00915.64
7.3.80.0080.00615.52
7.3.70.0090.00515.54
7.3.60.0050.00715.54
7.3.50.0060.00615.57
7.3.40.0030.00615.65
7.3.30.0060.00815.53
7.3.20.0080.00617.29
7.3.10.0060.00817.48
7.3.00.0020.00817.46
7.2.330.0090.00916.86
7.2.320.0100.00716.76
7.2.310.0120.01216.79
7.2.300.0100.00716.59
7.2.290.0150.00616.90
7.2.260.0030.01616.73
7.2.250.0050.01615.98
7.2.240.0080.00615.83
7.2.230.0060.01016.03
7.2.220.0070.00815.82
7.2.210.0030.00915.78
7.2.200.0050.01015.82
7.2.190.0070.00715.69
7.2.180.0050.00915.65
7.2.170.0100.00515.81
7.2.160.0030.01315.80
7.2.150.0090.00817.62
7.2.140.0110.00317.71
7.2.130.0100.00517.73
7.2.120.0090.00717.72
7.2.110.0040.01117.69
7.2.100.0070.00917.65
7.2.90.0050.01017.73
7.2.80.0050.01017.68
7.2.70.0050.01217.72
7.2.60.0070.00817.50
7.2.50.0030.01017.81
7.2.40.0070.00917.77
7.2.30.0050.00717.61
7.2.20.0080.00817.72
7.2.10.0090.00517.58
7.2.00.0050.01018.36
7.1.330.0080.00916.45
7.1.320.0050.00916.32
7.1.310.0070.00616.52
7.1.300.0080.00616.44
7.1.290.0080.00616.45
7.1.280.0070.01116.66
7.1.270.0050.00816.63
7.1.260.0040.00916.56
7.1.250.0030.01116.44
7.1.240.0070.00616.58
7.1.230.0130.00216.57
7.1.220.0050.00716.52
7.1.210.0070.01016.39
7.1.200.0080.00616.32
7.1.190.0070.00716.45
7.1.180.0030.00916.33
7.1.170.0030.01016.55
7.1.160.0090.00716.49
7.1.150.0080.00416.55
7.1.140.0100.00816.61
7.1.130.0090.00616.48
7.1.120.0000.01216.54
7.1.110.0100.00516.54
7.1.100.0040.00617.08
7.1.90.0050.01016.55
7.1.80.0050.00916.59
7.1.70.0050.00616.51
7.1.60.0070.01117.61
7.1.50.0060.00516.65
7.1.40.0070.00516.49
7.1.30.0050.00716.47
7.1.20.0020.01116.51
7.1.10.0020.01316.46
7.1.00.0020.03218.44
7.0.330.0070.00416.30
7.0.320.0060.00616.05
7.0.310.0060.00616.13
7.0.300.0030.01216.22
7.0.290.0070.00816.18
7.0.280.0020.00816.03
7.0.270.0090.00416.12
7.0.260.0060.00516.30
7.0.250.0040.01116.11
7.0.240.0070.00716.19
7.0.230.0020.01216.17
7.0.220.0110.00516.10
7.0.210.0050.00716.25
7.0.200.0060.00616.34
7.0.190.0030.01116.05
7.0.180.0060.00516.28
7.0.170.0080.00616.34
7.0.160.0070.00416.27
7.0.150.0060.00916.14
7.0.140.0100.02318.19
7.0.130.0070.00516.27
7.0.120.0050.00716.13
7.0.110.0090.00716.21
7.0.100.0070.00516.30
7.0.90.0050.00916.15
7.0.80.0060.00616.10
7.0.70.0020.01116.31
7.0.60.0100.02617.34
7.0.50.0060.02116.71
7.0.40.0030.02716.29
7.0.30.0090.03416.16
7.0.20.0100.01816.20
7.0.10.0160.02916.24
7.0.00.0080.02616.17
5.6.400.0070.00915.32
5.6.390.0080.00515.20
5.6.380.0090.00515.27
5.6.370.0040.00815.18
5.6.360.0050.01115.47
5.6.350.0080.00815.16
5.6.340.0020.01015.00
5.6.330.0050.00715.16
5.6.320.0080.00615.14
5.6.310.0110.00415.31
5.6.300.0070.00415.34
5.6.290.0040.00815.13
5.6.280.0090.02617.06
5.6.270.0060.00915.02
5.6.260.0070.00615.15
5.6.250.0050.00915.13
5.6.240.0060.00715.12
5.6.230.0070.00515.10
5.6.220.0050.01015.15
5.6.210.0030.03216.99
5.6.200.0070.02616.24
5.6.190.0040.02817.02
5.6.180.0130.03116.93
5.6.170.0110.03216.81
5.6.160.0040.01916.91
5.6.150.0060.02116.13
5.6.140.0070.02116.23
5.6.130.0050.03216.16
5.6.120.0080.02917.25
5.6.110.0070.02517.02
5.6.100.0090.01817.17
5.6.90.0100.03217.20
5.6.80.0090.03216.78
5.6.70.0090.02416.93
5.6.60.0000.01315.29
5.6.50.0080.00515.11
5.6.40.0050.00715.23
5.6.30.0050.00515.16
5.6.20.0060.00615.00
5.6.10.0090.00615.13
5.6.00.0060.00515.13
5.5.380.0050.00715.05
5.5.370.0020.01015.14
5.5.360.0120.00015.02
5.5.350.1470.02016.97
5.5.340.0060.01816.11
5.5.330.0030.02916.83
5.5.320.0030.02016.88
5.5.310.0180.02716.79
5.5.300.0010.03515.94
5.5.290.0040.02215.94
5.5.280.0110.02817.01
5.5.270.0070.02217.08
5.5.260.0060.03616.88
5.5.250.0050.02716.88
5.5.240.0030.03216.71
5.5.230.0050.01115.09
5.5.220.0030.01015.10
5.5.210.0060.00815.00
5.5.200.0020.01115.07
5.5.190.0060.00814.78
5.5.180.0090.00814.88
5.5.170.0050.00714.95
5.5.160.0080.00715.09
5.5.150.0050.00915.15
5.5.140.0090.00315.04
5.5.130.0070.00814.87
5.5.120.0070.01015.18
5.5.110.0090.00715.21
5.5.100.0040.00914.91
5.5.90.0070.00714.99
5.5.80.0090.00615.10
5.5.70.0020.01215.06
5.5.60.0020.01115.11
5.5.50.0070.00715.01
5.5.40.0040.01114.88
5.5.30.0080.00315.04
5.5.20.0030.00914.97
5.5.10.0020.01214.92
5.5.00.0070.00814.86
5.4.450.0040.02514.51
5.4.440.0370.02014.38
5.4.430.0210.02614.44
5.4.420.0340.02414.42
5.4.410.0410.02614.32
5.4.400.0120.01914.29
5.4.390.0140.02814.14
5.4.380.0030.02614.21
5.4.370.0050.02014.20
5.4.360.0060.01814.18
5.4.350.0050.01511.93
5.4.340.0040.01611.93
5.4.330.0040.00511.92
5.4.320.0070.01312.05
5.4.310.0030.01812.06
5.4.300.0040.01912.06
5.4.290.0130.02312.12
5.4.280.0080.02312.09
5.4.270.0090.02712.01
5.4.260.0070.02312.10
5.4.250.0080.01912.09
5.4.240.0080.01912.06
5.4.230.0070.01912.12
5.4.220.0140.02712.00
5.4.210.0100.03012.03
5.4.200.0060.02312.03
5.4.190.0070.02412.10
5.4.180.0060.03112.05
5.4.170.0060.02512.10
5.4.160.0080.02412.04
5.4.150.0120.02912.03
5.4.140.0050.02312.05
5.4.130.0110.02911.89
5.4.120.0120.02511.90
5.4.110.0050.02211.90
5.4.100.0130.03511.92
5.4.90.0130.02911.88
5.4.80.0080.02711.94
5.4.70.0150.03611.88
5.4.60.0140.03811.93
5.4.50.0070.02211.96
5.4.40.0060.02911.88
5.4.30.0080.03511.88
5.4.20.0100.03011.90
5.4.10.0060.02411.88
5.4.00.0060.02111.72
5.3.290.0030.02012.21
5.3.280.0060.02112.12
5.3.270.0050.03112.16
5.3.260.0050.02012.16
5.3.250.0060.02012.16
5.3.240.0070.02012.13
5.3.230.0090.03512.11
5.3.220.0060.02112.10
5.3.210.0060.02612.10
5.3.200.0070.03012.10
5.3.190.0050.02412.10
5.3.180.0050.02612.14
5.3.170.0150.03212.14
5.3.160.0080.02812.14
5.3.150.0170.03712.16
5.3.140.0110.03412.13
5.3.130.0120.03912.14
5.3.120.0060.03112.14
5.3.110.0080.03412.12
5.3.100.0100.03611.92
5.3.90.0110.03411.96
5.3.80.0060.02411.93
5.3.70.0050.02411.91
5.3.60.0060.01711.95
5.3.50.0040.02011.91
5.3.40.0090.02811.89
5.3.30.0030.02611.88
5.3.20.0080.02411.85
5.3.10.0100.02511.79
5.3.00.0090.03011.79
5.2.170.0100.0669.23
5.2.160.0170.0909.24
5.2.150.0070.0399.24
5.2.140.0120.0719.24
5.2.130.0120.1039.20
5.2.120.0090.0469.20
5.2.110.0070.0479.20
5.2.100.0070.0499.20
5.2.90.0060.0439.20
5.2.80.0080.0509.19
5.2.70.0070.0459.19
5.2.60.0080.0739.15
5.2.50.0070.0719.12
5.2.40.0120.0769.10
5.2.30.0090.0599.06
5.2.20.0210.0899.05
5.2.10.0100.0678.96
5.2.00.0110.0618.82
5.1.60.0050.0358.11
5.1.50.0060.0358.11
5.1.40.0080.0528.09
5.1.30.0130.0568.43
5.1.20.0100.0578.45
5.1.10.0080.0378.19
5.1.00.0090.0388.19
5.0.50.0050.0326.67
5.0.40.0240.0666.53
5.0.30.0100.0616.33
5.0.20.0090.0496.30
5.0.10.0060.0426.28
5.0.00.0070.0436.28
4.4.90.0040.0234.78
4.4.80.0040.0224.75
4.4.70.0020.0234.75
4.4.60.0050.0194.76
4.4.50.0050.0224.77
4.4.40.0050.0344.71
4.4.30.0030.0294.76
4.4.20.0040.0424.85
4.4.10.0050.0224.85
4.4.00.0050.0294.76
4.3.110.0030.0224.67
4.3.100.0070.0144.66
4.3.90.0040.0184.63
4.3.80.0040.0284.59
4.3.70.0080.0144.63
4.3.60.0030.0184.63
4.3.50.0040.0184.63
4.3.40.0100.0584.54
4.3.30.0050.0223.30
4.3.20.0040.0273.28
4.3.10.0030.0173.24
4.3.00.0000.0237.14

preferences:
135.05 ms | 403 KiB | 5 Q