3v4l.org

run code in 300+ PHP versions simultaneously
<?php class InfiniteLoggingIterator implements Iterator { public function __construct() { $this->position = 0; } public function rewind() { echo __METHOD__, PHP_EOL; $this->position = 0; } public function current() { echo __METHOD__, PHP_EOL; return $this->position; } public function key() { echo __METHOD__, PHP_EOL; return $this->position; } public function next() { echo __METHOD__, PHP_EOL; ++$this->position; } public function valid() { echo __METHOD__, PHP_EOL; return true; } } $i = new LimitIterator(new InfiniteLoggingIterator, 0, 2); echo "Rewinding outer iterator\n"; $i->rewind(); echo "\nGetting 1st value\n"; echo $i->valid() ? "Valid\n" : "Not valid\n"; echo "Current key: ", $i->key() ?? 'NULL', "\n"; echo "Current value: ", $i->current() ?? 'NULL', "\n"; echo "Proceeding to 2nd value\n"; $i->next(); echo "\nGetting 2nd (and last) value\n"; echo $i->valid() ? "Valid\n" : "Not valid\n"; echo "Current key: ", $i->key() ?? 'NULL', "\n"; echo "Current value: ", $i->current() ?? 'NULL', "\n"; echo "Proceeding to 3rd value\n"; $i->next(); echo "\nGetting 3rd value (beyond limit)\n"; echo $i->valid() ? "Valid\n" : "Not valid\n"; echo "Current key: ", $i->key() ?? 'NULL', "\n"; echo "Current value: ", $i->current() ?? 'NULL', "\n"; echo "Proceeding to 4th value!\n"; $i->next();

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.0120.00616.88
8.3.50.0060.01218.41
8.3.40.0130.00318.82
8.3.30.0120.00818.60
8.3.20.0050.00324.18
8.3.10.0080.00024.66
8.3.00.0070.00026.16
8.2.180.0110.00425.92
8.2.170.0110.00418.98
8.2.160.0090.00922.96
8.2.150.0050.00325.66
8.2.140.0050.00324.66
8.2.130.0000.00826.16
8.2.120.0040.00426.35
8.2.110.0030.00722.08
8.2.100.0140.00018.03
8.2.90.0050.00319.36
8.2.80.0040.00417.97
8.2.70.0000.00817.63
8.2.60.0160.00017.80
8.2.50.0000.01118.07
8.2.40.0000.00818.10
8.2.30.0040.00418.08
8.2.20.0030.00518.15
8.2.10.0030.00521.09
8.2.00.0040.00419.39
8.1.280.0140.00725.92
8.1.270.0060.00323.95
8.1.260.0070.00028.09
8.1.250.0060.00328.09
8.1.240.0030.00620.73
8.1.230.0040.00820.97
8.1.220.0060.00317.74
8.1.210.0040.00418.77
8.1.200.0030.00617.47
8.1.190.0060.00317.23
8.1.180.0040.00418.10
8.1.170.0090.00018.49
8.1.160.0040.00418.83
8.1.150.0090.00018.92
8.1.140.0070.00018.83
8.1.130.0030.00320.04
8.1.120.0040.00417.51
8.1.110.0080.00017.39
8.1.100.0030.00517.41
8.1.90.0000.00717.46
8.1.80.0040.00417.49
8.1.70.0000.00917.50
8.1.60.0090.00017.61
8.1.50.0030.00517.43
8.1.40.0000.00817.56
8.1.30.0070.00317.59
8.1.20.0030.00517.64
8.1.10.0040.00417.50
8.1.00.0100.00317.54
8.0.300.0040.00418.77
8.0.290.0030.00516.61
8.0.280.0000.00718.49
8.0.270.0000.00718.04
8.0.260.0040.00418.39
8.0.250.0030.00317.01
8.0.240.0030.00316.88
8.0.230.0040.00416.90
8.0.220.0030.00316.96
8.0.210.0030.00316.81
8.0.200.0000.00716.95
8.0.190.0040.00417.00
8.0.180.0000.00716.86
8.0.170.0040.00416.85
8.0.160.0040.00417.00
8.0.150.0030.00416.76
8.0.140.0040.00416.78
8.0.130.0000.00613.32
8.0.120.0040.00716.80
8.0.110.0040.00416.79
8.0.100.0040.00416.84
8.0.90.0040.00416.90
8.0.80.0060.01516.95
8.0.70.0040.00416.80
8.0.60.0040.00416.95
8.0.50.0050.00316.81
8.0.30.0130.00816.94
8.0.20.0060.01616.97
8.0.10.0070.01417.07
8.0.00.0090.01217.12
7.4.330.0000.00515.55
7.4.320.0000.00616.44
7.4.300.0030.00616.64
7.4.290.0000.00816.54
7.4.280.0000.00716.51
7.4.270.0030.00316.64
7.4.260.0000.00513.30
7.4.250.0000.00716.41
7.4.240.0000.00716.59
7.4.230.0070.00016.61
7.4.220.0030.00316.42
7.4.210.0060.01016.65
7.4.200.0000.00816.62
7.4.160.0000.01616.49
7.4.150.0180.00316.67
7.4.140.0130.00516.44
7.4.130.0160.00516.42
7.4.120.0120.00516.50
7.4.110.0120.00616.54
7.4.100.0060.01516.64
7.4.90.0030.01816.43
7.4.80.0030.01616.58
7.4.70.0180.00516.37
7.4.60.0070.00916.44
7.4.50.0090.01316.51
7.4.40.0110.01216.46
7.4.30.0130.01316.47
7.4.20.0070.01416.46
7.4.10.0130.00916.64
7.4.00.0100.01216.42
7.3.330.0060.00016.33
7.3.320.0030.00313.09
7.3.310.0030.00316.14
7.3.300.0070.00016.38
7.3.290.0060.01016.35
7.3.270.0030.01816.32
7.3.260.0120.00616.35
7.3.250.0100.01016.30
7.3.240.0030.01316.29
7.3.230.0030.01516.25
7.3.220.0120.00616.24
7.3.210.0120.00916.24
7.3.200.0020.01216.33
7.3.190.0030.01916.18
7.3.180.0170.00616.32
7.3.170.0040.01816.25
7.3.160.0110.01116.20
7.3.150.0130.00916.26
7.3.140.0000.02116.25
7.3.130.0040.01816.25
7.3.120.0090.01216.27
7.3.110.0120.00616.16
7.3.100.0120.00916.19
7.3.90.0120.00816.50
7.3.80.0160.00316.28
7.3.70.0130.00316.40
7.3.60.0160.00616.38
7.3.50.0060.01516.34
7.3.40.0030.01716.37
7.3.30.0120.00916.43
7.3.20.0110.00616.42
7.3.10.0060.01016.45
7.3.00.0110.00516.48
5.6.400.0110.01015.56

preferences:
78.18 ms | 400 KiB | 5 Q