3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface DbAdapterInterface { /** * @param DateTime $date * @return string */ public function convertFromDateTime(DateTime $date); /** * @param DateTime $date * @return array */ public function convertToDateTime(array $row); } class MySqlAdapter implements DbAdapterInterface { public function convertFromDateTime(DateTime $date) { return $date->format('Y-m-d H:i:s'); } public function convertToDateTime(array $row) { return new DateTime($row['date']); } } class OracleAdapter implements DbAdapterInterface { public function convertFromDateTime(DateTime $date) { return $date->getTimestamp(); } public function convertToDateTime(array $row) { return new DateTime('@'.$row['date']); } } class Db { /** @var DbAdapterInterface $adapter */ private $adapter; public function setAdapter(DbAdapterInterface $adapter) { $this->adapter = $adapter; } public function insert($data) { $date = $data['date']; $dateString = $this->adapter->convertFromDateTime($date); // do your insert return $dateString; } public function findById($id) { // fetch row by id here, this is just an example, I'm using the id as the date string $row = ['date' => $id]; $row = $this->adapter->convertToDateTime($row); // do your insert return $row; } } // Example $data = [ 'date' => new DateTime(), ]; $db = new Db(); $db->setAdapter(new MySqlAdapter()); echo $db->insert($data)."\n"; $db->setAdapter(new OracleAdapter()); echo $db->insert($data)."\n"; $time = '1493308146'; var_dump( $db->findById($time)); $db->setAdapter(new MySqlAdapter()); $time = '2014-09-18 22:00:00'; var_dump( $db->findById($time));

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.0120.00823.94
8.4.110.0080.01118.96
8.4.100.0100.01017.84
8.4.90.0150.00620.63
8.4.80.0150.00519.18
8.4.70.0070.00818.83
8.4.60.0130.00819.07
8.4.50.0060.00319.69
8.4.40.0160.00319.35
8.4.30.0170.00319.72
8.4.20.0070.01417.68
8.4.10.0040.00818.14
8.3.250.0070.00218.83
8.3.240.0120.00816.87
8.3.230.0150.00516.70
8.3.220.0040.00419.00
8.3.210.0050.00418.53
8.3.200.0030.00616.56
8.3.190.0090.01017.20
8.3.180.0110.00917.14
8.3.170.0120.00616.82
8.3.160.0100.00716.89
8.3.150.0060.00317.04
8.3.140.0000.01517.20
8.3.130.0150.00018.58
8.3.120.0030.00719.00
8.3.110.0160.00020.94
8.3.100.0040.00424.06
8.3.90.0030.00626.77
8.3.80.0110.00019.36
8.3.70.0100.01016.86
8.3.60.0040.01116.50
8.3.50.0110.00521.27
8.3.40.0150.00618.89
8.3.30.0110.00718.92
8.3.20.0030.00520.23
8.3.10.0040.00421.75
8.3.00.0060.00318.13
8.2.290.0110.00716.71
8.2.280.0050.00318.45
8.2.270.0060.00617.03
8.2.260.0040.01118.96
8.2.250.0060.01016.97
8.2.240.0100.01017.20
8.2.230.0000.01122.58
8.2.220.0040.00837.54
8.2.210.0050.00326.77
8.2.200.0090.00018.88
8.2.190.0120.00616.58
8.2.180.0120.00318.54
8.2.170.0070.00719.02
8.2.160.0080.00622.96
8.2.150.0070.00024.18
8.2.140.0100.00024.66
8.2.130.0070.00026.16
8.2.120.0080.00021.11
8.2.110.0060.00322.06
8.2.100.0070.00419.32
8.2.90.0040.00418.16
8.2.80.0050.00317.97
8.2.70.0060.00318.05
8.2.60.0030.00518.22
8.2.50.0030.00618.10
8.2.40.0000.00720.57
8.2.30.0070.00019.42
8.2.20.0040.00418.21
8.2.10.0040.00418.32
8.2.00.0050.00218.49
8.1.330.0080.00416.39
8.1.320.0140.00818.16
8.1.310.0110.00718.47
8.1.300.0080.00018.50
8.1.290.0000.01030.84
8.1.280.0180.00425.92
8.1.270.0040.00423.85
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0130.01020.56
8.1.230.0080.00322.62
8.1.220.0040.00419.04
8.1.210.0040.00418.77
8.1.200.0000.01217.38
8.1.190.0000.00817.38
8.1.180.0000.00818.10
8.1.170.0050.00318.86
8.1.160.0040.00418.94
8.1.150.0080.00020.23
8.1.140.0050.00219.63
8.1.130.0000.00719.01
8.1.120.0070.00017.72
8.1.110.0030.00617.60
8.1.100.0040.00417.61
8.1.90.0000.00717.63
8.1.80.0040.00417.68
8.1.70.0000.00717.58
8.1.60.0000.00817.62
8.1.50.0030.00517.66
8.1.40.0000.00817.56
8.1.30.0000.00817.70
8.1.20.0000.00817.80
8.1.10.0050.00317.72
8.1.00.0080.00017.71
8.0.300.0070.00021.64
8.0.290.0040.00416.88
8.0.280.0000.00818.54
8.0.270.0030.00317.28
8.0.260.0000.00819.03
8.0.250.0030.00317.20
8.0.240.0050.00317.12
8.0.230.0000.00717.28
8.0.220.0030.00517.14
8.0.210.0000.00717.19
8.0.200.0060.00017.13
8.0.190.0000.00817.25
8.0.180.0080.00017.16
8.0.170.0030.00517.23
8.0.160.0000.00817.23
8.0.150.0080.00017.13
8.0.140.0070.00017.12
8.0.130.0030.00313.50
8.0.120.0040.00417.05
8.0.110.0000.00717.07
8.0.100.0000.00717.16
8.0.90.0050.00217.01
8.0.80.0040.01217.11
8.0.70.0070.00017.13
8.0.60.0040.00417.14
8.0.50.0000.00717.05
8.0.30.0110.00717.35
8.0.20.0100.00917.40
8.0.10.0030.00617.36
8.0.00.0090.00916.79
7.4.330.0000.00615.55
7.4.320.0060.00316.60
7.4.300.0030.00316.68
7.4.290.0070.00016.74
7.4.280.0030.00716.73
7.4.270.0000.00716.72
7.4.260.0040.00416.70
7.4.250.0030.00516.58
7.4.240.0030.00416.53
7.4.230.0040.00416.50
7.4.220.0080.01116.68
7.4.210.0090.00616.79
7.4.200.0000.00816.78
7.4.160.0070.01216.75
7.4.150.0100.01317.40
7.4.140.0110.01017.86
7.4.130.0080.01016.72
7.4.120.0090.01316.69
7.4.110.0100.00716.81
7.4.100.0090.00916.68
7.4.90.0060.01016.92
7.4.80.0070.02019.39
7.4.70.0060.01216.59
7.4.60.0070.01116.55
7.4.50.0030.01016.51
7.4.40.0170.00916.59
7.4.30.0090.00816.55
7.4.00.0030.01015.01
7.3.330.0050.00313.38
7.3.320.0030.00313.45
7.3.310.0000.00716.57
7.3.300.0000.00716.53
7.3.290.0020.01116.52
7.3.280.0100.00816.51
7.3.270.0080.01117.40
7.3.260.0110.00916.54
7.3.250.0160.00616.63
7.3.240.0080.01316.63
7.3.230.0120.00916.77
7.3.210.0180.00716.71
7.3.200.0080.01216.80
7.3.190.0060.01216.68
7.3.180.0070.01116.62
7.3.170.0100.00716.68
7.3.160.0080.01116.64
7.2.330.0120.00617.02
7.2.320.0070.01116.79
7.2.310.0110.00617.04
7.2.300.0030.01517.04
7.2.290.0090.00816.79
7.2.60.0000.01517.15
7.2.00.0070.00719.59
7.1.200.0070.00716.09
7.1.70.0060.00917.45
7.1.60.0060.00617.55
7.1.50.0130.01017.26
7.1.40.0130.01334.55
7.1.30.0230.01034.59
7.1.20.0170.01334.62
7.1.10.0000.01316.70
7.1.00.0070.01016.67
7.0.200.0000.01016.71
7.0.180.0030.01316.41
7.0.170.0070.01016.30
7.0.160.0100.00716.41
7.0.150.0030.01016.19
7.0.140.0070.00716.31
7.0.130.0000.01016.68
7.0.120.0000.01316.68
7.0.110.0030.01016.29
7.0.100.0030.00716.36
7.0.90.0030.01316.35
7.0.80.0000.01716.58
7.0.70.0000.01016.28
7.0.60.0000.01016.02
7.0.50.0070.01016.26
7.0.40.0070.00716.48
7.0.30.0000.01016.51
7.0.20.0000.01016.32
7.0.10.0030.00716.39
7.0.00.0000.01016.41

preferences:
33.32 ms | 403 KiB | 5 Q