3v4l.org

run code in 300+ PHP versions simultaneously
<?php class RewindableGenerator implements Iterator { private $rewound; private $iteratorConstructor; private $iterator; function __construct(callable $iteratorConstructor){ $this->iteratorConstructor = $iteratorConstructor; $this->rewind(); } function rewind(){ if(!$this->rewound){ $this->iterator = ($this->iteratorConstructor)(); $this->rewound = true; } } function next(){ $this->iterator->next(); $this->rewound = false; } function valid(){ return $this->iterator->valid(); } function key(){ return $this->iterator->key(); } function current(){ return $this->iterator->current(); } } function test(){ yield 0; yield 1; yield 2; yield 3; yield 4; } function baz(){ return new RewindableGenerator('test'); } $gen = baz(); echo $gen->current() . " 0\n"; $gen->next(); echo $gen->current() . " 1\n"; $gen->next(); echo $gen->current() . " 2\n"; $gen->next(); echo $gen->current() . " 3\n"; echo "rewind\n"; $gen->rewind(); echo $gen->current() . " 0\n"; $gen->next(); echo $gen->current() . " 1\n"; $gen->next(); echo $gen->current() . " 2\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.3.70.0090.00616.88
8.3.60.0140.00418.41
8.3.50.0160.00521.02
8.3.40.0090.00618.84
8.3.30.0110.00418.83
8.3.20.0030.00519.23
8.3.10.0040.00421.77
8.3.00.0080.00019.81
8.2.190.0090.00616.63
8.2.180.0210.00018.29
8.2.170.0070.00722.96
8.2.160.0100.00322.25
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0060.00319.42
8.2.120.0050.00326.35
8.2.110.0090.00020.50
8.2.100.0070.00417.80
8.2.90.0060.00319.08
8.2.80.0030.00517.97
8.2.70.0030.00617.50
8.2.60.0040.00418.04
8.2.50.0030.00518.07
8.2.40.0040.00419.05
8.2.30.0030.00620.46
8.2.20.0000.00717.72
8.2.10.0070.00018.16
8.2.00.0030.00617.95
8.1.280.0070.00725.92
8.1.270.0050.00323.91
8.1.260.0040.00428.09
8.1.250.0030.00528.09
8.1.240.0090.00022.01
8.1.230.0060.00617.79
8.1.220.0000.00817.74
8.1.210.0060.00318.77
8.1.200.0090.00017.35
8.1.190.0080.00017.25
8.1.180.0080.00018.10
8.1.170.0030.00620.44
8.1.160.0000.00721.95
8.1.150.0040.00418.79
8.1.140.0030.00519.62
8.1.130.0030.00317.74
8.1.120.0080.00017.48
8.1.110.0040.00417.53
8.1.100.0000.00817.42
8.1.90.0030.00517.44
8.1.80.0040.00417.38
8.1.70.0060.00317.41
8.1.60.0030.00617.61
8.1.50.0030.00617.61
8.1.40.0000.00817.51
8.1.30.0090.00017.66
8.1.20.0030.00617.63
8.1.10.0030.00617.54
8.1.00.0000.00817.46
8.0.300.0040.00418.77
8.0.290.0040.00416.63
8.0.280.0070.00018.47
8.0.270.0000.00817.30
8.0.260.0000.00717.26
8.0.250.0070.00017.02
8.0.240.0040.00417.09
8.0.230.0070.00016.93
8.0.220.0040.00416.94
8.0.210.0040.00417.00
8.0.200.0030.00317.06
8.0.190.0000.00917.11
8.0.180.0000.00717.03
8.0.170.0000.00916.98
8.0.160.0000.00716.89
8.0.150.0040.00416.85
8.0.140.0000.00716.99
8.0.130.0000.00913.45
8.0.120.0040.00416.98
8.0.110.0000.00716.88
8.0.100.0070.00016.83
8.0.90.0000.00716.82
8.0.80.0060.00916.97
8.0.70.0030.00517.02
8.0.60.0030.00516.77
8.0.50.0040.00416.80
8.0.30.0100.01017.03
8.0.20.0090.01117.40
8.0.10.0040.00417.17
8.0.00.0140.00716.86
7.4.330.0000.00515.08
7.4.320.0030.00316.55
7.4.300.0000.00616.58
7.4.290.0070.00316.67
7.4.280.0050.00316.52
7.4.270.0070.00016.61
7.4.260.0030.00716.66
7.4.250.0000.00716.49
7.4.240.0000.00716.43
7.4.230.0030.00316.64
7.4.220.0060.01216.46
7.4.210.0060.00916.60
7.4.200.0000.00716.63
7.4.160.0090.00616.55
7.4.150.0110.01117.40
7.4.140.0090.00917.86
7.4.130.0140.00416.51
7.4.120.0090.00916.52
7.4.110.0100.00716.40
7.4.100.0070.01016.57
7.4.90.0160.00616.57
7.4.80.0100.00719.39
7.4.70.0090.00616.69
7.4.60.0120.00416.44
7.4.50.0060.00916.21
7.4.40.0100.00716.49
7.4.30.0120.00616.50
7.4.00.0060.00914.93
7.3.330.0000.00813.10
7.3.320.0030.00313.12
7.3.310.0050.00316.16
7.3.300.0000.00716.34
7.3.290.0070.00016.23
7.3.280.0100.00916.30
7.3.270.0140.00417.40
7.3.260.0120.00716.47
7.3.250.0110.00716.30
7.3.240.0160.00116.35
7.3.230.0100.00616.49
7.3.210.0090.01216.54
7.3.200.0080.00816.40
7.3.190.0140.00316.32
7.3.180.0110.00716.62
7.3.170.0140.00716.36
7.3.160.0040.01216.45
7.2.330.0100.01316.64
7.2.320.0100.01316.80
7.2.310.0120.00616.46
7.2.300.0070.01016.79
7.2.290.0110.00616.70
7.2.60.0030.01016.83
7.2.00.0070.00719.55
7.1.200.0070.00715.56
7.1.100.0200.00717.75
7.1.70.0000.00717.23
7.1.60.0140.01019.54
7.1.50.0070.01416.80
7.1.00.0070.07322.31
7.0.200.0090.00616.81
7.0.60.0200.05019.95
7.0.50.0400.04720.51
7.0.40.0270.05720.51
7.0.30.0300.06320.37
7.0.20.0370.05720.50
7.0.10.0330.05720.49
7.0.00.0200.05320.27
5.6.280.0000.07720.90
5.6.210.0070.06020.68
5.6.200.0270.06021.21
5.6.190.0270.05721.09
5.6.180.0200.06021.03
5.6.170.0300.05721.14
5.6.160.0270.05721.13
5.6.150.0470.04021.02
5.6.140.0200.05721.09
5.6.130.0100.06021.01
5.6.120.0430.05021.05
5.6.110.0300.06021.12
5.6.100.0230.06021.05
5.6.90.0400.05321.04
5.6.80.0430.04720.50
5.6.70.0300.05320.50
5.6.60.0200.04320.30
5.6.50.0270.05020.55
5.6.40.0230.06320.44
5.6.30.0370.04320.45
5.6.20.0070.06020.42
5.6.10.0370.04020.41
5.6.00.0170.05720.47
5.5.350.0270.05720.46
5.5.340.0370.04720.88
5.5.330.0270.05320.95
5.5.320.0400.05020.85
5.5.310.0470.04320.83
5.5.300.0200.06020.86
5.5.290.0170.05320.91
5.5.280.0230.05720.84
5.5.270.0130.06720.86
5.5.260.0330.05720.95
5.5.250.0230.06020.69
5.5.240.0330.05020.13
5.5.230.0170.06020.25
5.5.220.0100.05320.21
5.5.210.0100.06320.33
5.5.200.0370.04720.07
5.5.190.0130.05720.18
5.5.180.0170.06020.21
5.5.160.0170.05320.15
5.5.150.0170.05020.14
5.5.140.0200.05320.07
5.5.130.0270.04320.21
5.5.120.0270.04720.12
5.5.110.0200.05320.18
5.5.100.0230.05019.96
5.5.90.0100.05320.17
5.5.80.0100.05720.09
5.5.70.0130.05320.19
5.5.60.0070.06020.09
5.5.50.0100.05720.26
5.5.40.0100.06020.18
5.5.30.0200.05020.18
5.5.20.0100.06020.18
5.5.10.0200.05020.02
5.5.00.0100.06320.03

preferences:
73.01 ms | 401 KiB | 5 Q