3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Workaround for date period iteration under php 5.2 * * @author pgorbach <pgorbach@goodgamestudios.com> * @package publishers * @version $Id$ */ class GgsDatePeriod implements Iterator { /** * @var \DateTime */ protected $current; /** * @var \DateTime */ protected $start; /** * @var \DateTime */ protected $end; /** * @var string */ protected $interval; /** * @todo replace this class by build in php class DatePeriod * * @param \DateTime $start * @param string $interval * @param \DateTime $end * @param int $options */ public function __construct($start, $interval, $end, $options = 0) { $this->start = $start; $this->end = $end; $this->interval = $interval; $this->current = clone($start); } /** * (PHP 5 &gt;= 5.0.0)<br/> * Return the current element * * @link http://php.net/manual/en/iterator.current.php * @return mixed Can return any type. */ public function current() { return $this->current; } /** * (PHP 5 &gt;= 5.0.0)<br/> * Move forward to next element * * @link http://php.net/manual/en/iterator.next.php * @return void Any returned value is ignored. */ public function next() { $this->current->modify($this->interval); } /** * (PHP 5 &gt;= 5.0.0)<br/> * Return the key of the current element * * @link http://php.net/manual/en/iterator.key.php * @return mixed scalar on success, or null on failure. */ public function key() { return strtotime($this->current()->format('Y-m-d')); } /** * (PHP 5 &gt;= 5.0.0)<br/> * Checks if current position is valid * * @link http://php.net/manual/en/iterator.valid.php * @return boolean The return value will be casted to boolean and then evaluated. * Returns true on success or false on failure. */ public function valid() { return $this->current() <= $this->end; } /** * (PHP 5 &gt;= 5.0.0)<br/> * Rewind the Iterator to the first element * * @link http://php.net/manual/en/iterator.rewind.php * @return void Any returned value is ignored. */ public function rewind() { $this->current = clone($this->start); } } $startDateTime = new DateTime('2010-01-01'); $endDateTime = new DateTime('2010-08-01'); $period = new GgsDatePeriod($startDateTime, 86400, $endDateTime); foreach ($period as $iterDate) { echo $iterDate->format('Y-m-d'); }

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.40.0070.00719.01
8.3.30.0170.00319.09
8.3.20.0150.00418.98
8.3.10.0050.00320.82
8.3.00.0120.00819.63
8.2.170.0080.00822.96
8.2.160.0100.01320.45
8.2.150.0070.00324.18
8.2.140.0230.01124.66
8.2.130.0030.00726.16
8.2.120.0030.00719.36
8.2.110.0060.00620.93
8.2.100.0040.01117.97
8.2.90.0040.00719.47
8.2.80.0030.00619.39
8.2.70.0030.00917.88
8.2.60.0040.00418.16
8.2.50.0070.00418.07
8.2.40.0040.00917.98
8.2.30.0030.00618.11
8.2.20.0040.00417.94
8.2.10.0030.00618.07
8.2.00.0000.00818.05
8.1.270.0100.00024.66
8.1.260.0050.00526.35
8.1.250.0070.00328.09
8.1.240.0100.00022.59
8.1.230.0060.00620.91
8.1.220.0000.00817.74
8.1.210.0000.00920.82
8.1.200.0000.01217.50
8.1.190.0000.00917.78
8.1.180.0000.01218.10
8.1.170.0040.00418.90
8.1.160.0060.00318.95
8.1.150.0030.00618.91
8.1.140.0080.00417.66
8.1.130.0000.00817.97
8.1.120.0000.00917.63
8.1.110.0080.00017.71
8.1.100.0030.00517.71
8.1.90.0000.00817.61
8.1.80.0040.00417.60
8.1.70.0080.00017.71
8.1.60.0030.00717.83
8.1.50.0100.00017.59
8.1.40.0000.01317.79
8.1.30.0000.00917.81
8.1.20.0000.00917.80
8.1.10.0030.00617.69
8.1.00.0030.00817.69
8.0.300.0060.00319.73
8.0.290.0030.00516.88
8.0.280.0030.00518.41
8.0.270.0050.00317.16
8.0.260.0050.00317.05
8.0.250.0000.00817.12
8.0.240.0110.00017.10
8.0.230.0040.00417.04
8.0.220.0000.00917.09
8.0.210.0000.01017.07
8.0.200.0040.00417.21
8.0.190.0030.00617.06
8.0.180.0030.00617.00
8.0.170.0060.00317.00
8.0.160.0030.00617.19
8.0.150.0070.00417.08
8.0.140.0000.00916.98
8.0.130.0050.00313.53
8.0.120.0060.00317.08
8.0.110.0000.00916.93
8.0.100.0090.00016.89
8.0.90.0040.00417.11
8.0.80.0000.02017.12
8.0.70.0040.00416.90
8.0.60.0000.00817.05
8.0.50.0000.01017.09
8.0.30.0130.01117.28
8.0.20.0130.01617.34
8.0.10.0090.00017.06
8.0.00.0160.01416.78
7.4.330.0030.00313.10
7.4.320.0070.00416.66
7.4.300.0050.00316.61
7.4.290.0060.00316.45
7.4.280.0070.00316.45
7.4.270.0030.00616.64
7.4.260.0030.00313.32
7.4.250.0000.01016.63
7.4.240.0070.00316.46
7.4.230.0040.00416.43
7.4.220.0090.02816.73
7.4.210.0120.01216.59
7.4.200.0040.00416.75
7.4.190.0040.00416.50
7.4.160.0180.00616.61
7.4.150.0180.01016.67
7.4.140.0140.01016.77
7.4.130.0170.00816.83
7.4.120.0180.01016.70
7.4.110.0130.01316.54
7.4.100.0030.02016.58
7.4.90.0200.01316.58
7.4.80.0120.01519.39
7.4.70.0070.01816.75
7.4.60.0170.00916.50
7.4.50.0060.00316.55
7.4.40.0030.01716.60
7.4.30.0220.00716.66
7.3.330.0000.00813.57
7.3.320.0020.00513.42
7.3.310.0040.00416.45
7.3.300.0050.00316.24
7.3.290.0130.01016.30
7.3.280.0100.01416.42
7.3.270.0160.00616.54
7.3.260.0140.01416.47
7.3.250.0190.01216.54
7.3.240.0100.01716.57
7.3.230.0000.02816.57
7.3.210.0060.01516.61
7.3.200.0120.01516.71
7.3.190.0100.02116.56
7.3.180.0120.01216.69
7.3.170.0130.01316.50
7.3.160.0100.01016.63
7.2.330.0090.01816.91
7.2.320.0180.01116.55
7.2.310.0070.02616.92
7.2.300.0160.00816.71
7.2.290.0190.00816.91
7.2.110.0000.01116.80
7.2.100.0000.01316.57
7.2.90.0090.00316.82
7.2.80.0040.01116.77
7.2.70.0070.01017.17
7.2.60.0060.00317.00
7.2.50.0000.01417.04
7.2.40.0110.00317.12
7.2.30.0030.01417.07
7.2.20.0060.00817.08
7.2.10.0070.00716.80
7.2.00.0050.00918.25
7.1.230.0070.00315.66
7.1.220.0100.00315.95
7.1.210.0040.00415.99
7.1.200.0070.00715.81
7.1.190.0070.00415.93
7.1.180.0050.00815.95
7.1.170.0070.00715.99
7.1.160.0040.00815.94
7.1.150.0030.01015.90
7.1.140.0060.00615.54
7.1.130.0070.00415.72
7.1.120.0100.00315.89
7.1.110.0120.00315.73
7.1.100.0040.00916.96
7.1.90.0070.00715.74
7.1.80.0100.00716.04
7.1.70.0030.00816.44
7.1.60.0130.00817.82
7.1.50.0130.01425.67
7.1.40.0130.00316.16
7.1.30.0120.00616.27
7.1.20.0100.00715.96
7.1.10.0030.01115.85
7.1.00.0020.00715.64
7.0.310.0090.00615.69
7.0.300.0000.01015.61
7.0.290.0030.01015.51
7.0.280.0030.00915.55
7.0.270.0000.01215.44
7.0.260.0100.00515.70
7.0.250.0030.01215.57
7.0.240.0000.01015.76
7.0.230.0090.00415.72
7.0.220.0030.01015.68
7.0.210.0000.01315.63
7.0.200.0040.00816.34
7.0.190.0030.01015.60
7.0.180.0060.00615.39
7.0.170.0000.01415.76
7.0.160.0090.00615.36
7.0.150.0030.01315.42
7.0.140.0070.00715.71
7.0.130.0030.00915.63
7.0.120.0000.01215.74
7.0.110.0070.00315.37
7.0.100.0080.00415.45
7.0.90.0110.00415.57
7.0.80.0030.00915.43
7.0.70.0070.00715.67
7.0.60.0030.01015.61
7.0.50.0060.00315.54
7.0.40.0040.00413.71
7.0.30.0100.00313.87
7.0.20.0060.00613.67
7.0.10.0100.00013.69
7.0.00.0060.00613.73
5.6.380.0110.00314.86
5.6.370.0120.00014.72
5.6.360.0060.00614.73
5.6.350.0030.01114.55
5.6.340.0040.00714.84
5.6.330.0060.00614.72
5.6.320.0070.01014.66
5.6.310.0040.00814.45
5.6.300.0100.00314.72
5.6.290.0080.00614.56
5.6.280.0060.00614.75
5.6.270.0060.00314.61
5.6.260.0070.00714.73
5.6.250.0090.00314.80
5.6.240.0030.01014.38
5.6.230.0060.00914.43
5.6.220.0000.01214.47
5.6.210.0040.01214.38
5.6.200.0030.00814.57
5.6.190.0140.00414.50
5.6.180.0040.01114.51
5.6.170.0080.00814.15
5.6.160.0100.00314.55
5.6.150.0070.00714.65
5.6.140.0040.00714.79
5.6.130.0050.00814.43
5.6.120.0000.01614.39
5.6.110.0050.00314.42
5.6.100.0060.00614.46
5.6.90.0030.00714.37
5.6.80.0090.00914.59
5.6.70.0040.00914.44
5.6.60.0150.00014.64
5.6.50.0030.01014.51
5.6.40.0030.01014.66
5.6.30.0030.00914.21
5.6.20.0040.00714.54
5.6.10.0110.00014.45
5.6.00.0040.00414.54
5.5.380.0040.00811.76
5.5.370.0050.00511.76
5.5.360.0040.00811.76
5.5.350.0030.00711.76
5.5.340.0070.00311.76
5.5.330.0100.00311.76
5.5.320.0040.00411.76
5.5.310.0030.00511.76
5.5.300.0000.01111.76
5.5.290.0000.00811.76
5.5.280.0060.00911.76
5.5.270.0070.00711.76
5.5.260.0040.01111.76
5.5.250.0030.01011.76
5.5.240.0030.01011.76
5.5.230.0080.00011.76
5.5.220.0090.00611.76
5.5.210.0040.00411.76
5.5.200.0030.01011.76
5.5.190.0040.00411.76
5.5.180.0090.00011.76
5.5.170.0030.01214.46
5.5.160.0040.00411.76
5.5.150.0060.00611.76
5.5.140.0100.00311.76
5.5.130.0030.00911.76
5.5.120.0030.00911.76
5.5.110.0040.00711.76
5.5.100.0030.00811.76
5.5.90.0060.00611.76
5.5.80.0000.00811.76
5.5.70.0030.00911.76
5.5.60.0080.00411.76
5.5.50.0050.00511.76
5.5.40.0030.00711.76
5.5.30.0070.00711.76
5.5.20.0070.01011.76
5.5.10.0000.00811.76
5.5.00.0060.00311.76
5.4.450.0030.00611.76
5.4.440.0030.00611.76
5.4.430.0070.00711.76
5.4.420.0060.00611.76
5.4.410.0000.01211.76
5.4.400.0000.01111.76
5.4.390.0000.01511.76
5.4.380.0030.01011.76
5.4.370.0030.00911.76
5.4.360.0030.00611.76
5.4.350.0000.00811.76
5.4.340.0030.00611.76
5.4.330.0000.00911.76
5.4.320.0000.01011.76
5.4.310.0000.00711.76
5.4.300.0000.01011.76
5.4.290.0060.00311.76
5.4.280.0030.01011.76
5.4.270.0030.01011.76
5.4.260.0000.01311.76
5.4.250.0030.00711.76
5.4.240.0000.00911.76
5.4.230.0100.00311.76
5.4.220.0000.01011.76
5.4.210.0030.00911.76
5.4.200.0000.00911.76
5.4.190.0050.00511.76
5.4.180.0140.00011.76
5.4.170.0040.00711.76
5.4.160.0040.00411.76
5.4.150.0030.00611.76
5.4.140.0040.00411.76
5.4.130.0100.00311.76
5.4.120.0060.00611.76
5.4.110.0070.00211.76
5.4.100.0110.00411.76
5.4.90.0000.00811.76
5.4.80.0030.01211.76
5.4.70.0140.00411.76
5.4.60.0030.01011.76
5.4.50.0000.01211.76
5.4.40.0000.00911.76
5.4.30.0070.00411.76
5.4.20.0050.00711.76
5.4.10.0070.00011.76
5.4.00.0060.00611.76
5.3.290.0030.00611.76
5.3.280.0090.00311.76
5.3.270.0030.00711.76
5.3.260.0040.00411.76
5.3.250.0040.00811.76
5.3.240.0100.00311.76
5.3.230.0060.00911.76
5.3.220.0000.00811.76
5.3.210.0080.00611.76
5.3.200.0060.00311.76
5.3.190.0050.00511.76
5.3.180.0000.01311.76
5.3.170.0050.00511.76
5.3.160.0050.00511.76
5.3.150.0040.00711.76
5.3.140.0000.00811.76
5.3.130.0070.00711.76
5.3.120.0070.00711.76
5.3.110.0000.01011.76
5.3.100.0030.00611.76
5.3.90.0090.00311.76
5.3.80.0090.00311.76
5.3.70.0050.00511.76
5.3.60.0000.00911.76
5.3.50.0040.00811.76
5.3.40.0040.00811.76
5.3.30.0050.00511.76
5.3.20.0030.00611.76
5.3.10.0070.02011.76
5.3.00.0060.01811.76

preferences:
48.42 ms | 400 KiB | 5 Q