3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Database { protected static $instance; protected $pdo; protected function __construct() { static $opt = [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, ]; $this->pdo = new PDO('sqlite::memory:', null, null, $opt); } public static function instance() { if (null === self::$instance) { self::$instance = new self; } return self::$instance; } public function run($sql, $args = []) { if (!$args) { return $this->query($sql); } $stmt = $this->prepare($sql); $stmt->execute($args); return $stmt; } public function __call($method, $args) { if (is_callable([$this->pdo, $method])) { //php 5.6+ variadic optimization (aka splat operator) return $this->pdo->$method(...$args); //PHP <= 5.5 //return call_user_func_array(array($this->pdo, $method), $args); } throw new \BadMethodCallException(sprintf('Unknown method PDO::%s called!', $method)); } } //RunTime code if (PHP_VERSION_ID >= 70100) { try { $db = Database::instance(); var_dump($db->run('SELECT ?', ['foo', 'bar'])->fetch()); } catch(\PDOException $e) { if ('execute' === $e->getTrace()[0]['function']) { echo 'PDO::execute() failed'; } //Handle the exception } } else { try { $db = Database::instance(); var_dump($db->run('SELECT ?', ['foo', 'bar'])->fetch()); } catch(\PDOException $e) { if ('execute' === $e->getTrace()[0]['function']) { echo 'PDO::execute() failed'; } //Handle the exception } }

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.0110.00419.31
8.3.60.0060.00919.18
8.3.50.0140.00617.45
8.3.40.0090.00619.48
8.3.30.0110.00419.71
8.3.20.0080.00021.58
8.3.10.0080.00021.08
8.3.00.0040.00424.29
8.2.190.0070.01419.54
8.2.180.0060.00917.63
8.2.170.0070.00722.96
8.2.160.0000.01521.10
8.2.150.0030.00624.18
8.2.140.0060.00324.66
8.2.130.0030.00526.16
8.2.120.0080.00026.16
8.2.110.0060.00622.96
8.2.100.0100.00318.72
8.2.90.0040.00418.59
8.2.80.0000.00819.89
8.2.70.0060.00320.13
8.2.60.0030.00618.50
8.2.50.0040.00418.21
8.2.40.0040.00420.03
8.2.30.0000.00720.16
8.2.20.0040.00418.77
8.2.10.0030.00619.69
8.2.00.0050.00320.20
8.1.280.0040.01525.92
8.1.270.0040.00423.29
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0000.01021.71
8.1.230.0090.00323.56
8.1.220.0090.00018.52
8.1.210.0050.00319.38
8.1.200.0040.00418.10
8.1.190.0080.00017.98
8.1.180.0030.00518.13
8.1.170.0050.00319.32
8.1.160.0050.00319.67
8.1.150.0000.00719.72
8.1.140.0040.00419.59
8.1.130.0070.00020.87
8.1.120.0000.00718.27
8.1.110.0050.00318.18
8.1.100.0030.00718.26
8.1.90.0050.00218.26
8.1.80.0000.00818.24
8.1.70.0040.00418.25
8.1.60.0000.00818.38
8.1.50.0030.00518.37
8.1.40.0060.00318.38
8.1.30.0040.00418.54
8.1.20.0030.00618.46
8.1.10.0060.00318.31
8.1.00.0040.00418.41
8.0.300.0050.00320.84
8.0.290.0070.00017.50
8.0.280.0040.00419.32
8.0.270.0040.00417.63
8.0.260.0000.00719.29
8.0.250.0000.00717.87
8.0.240.0000.00817.86
8.0.230.0030.00317.88
8.0.220.0000.00717.79
8.0.210.0000.00917.87
8.0.200.0030.00317.80
8.0.190.0040.00417.70
8.0.180.0030.00517.75
8.0.170.0000.00817.77
8.0.160.0000.00817.63
8.0.150.0040.00417.69
8.0.140.0000.00717.59
8.0.130.0030.00314.20
8.0.120.0000.00717.70
8.0.110.0080.00017.75
8.0.100.0040.00417.55
8.0.90.0040.00417.52
8.0.80.0110.00517.74
8.0.70.0080.00017.73
8.0.60.0000.00817.81
8.0.50.0040.00417.67
8.0.30.0080.01217.84
8.0.20.0130.00617.91
8.0.10.0000.00717.72
8.0.00.0110.01017.48
7.4.330.0030.00315.90
7.4.320.0070.00017.37
7.4.300.0030.00317.29
7.4.290.0000.00817.41
7.4.280.0000.00817.17
7.4.270.0030.00717.32
7.4.260.0040.00417.28
7.4.250.0000.00817.29
7.4.240.0030.00317.31
7.4.230.0000.00717.02
7.4.220.0030.00617.23
7.4.210.0040.01317.41
7.4.200.0000.00817.31
7.4.160.0100.00917.27
7.4.140.0070.01117.86
7.4.130.0090.01017.44
7.4.120.0090.00917.42
7.4.110.0190.00617.52
7.4.100.0100.01317.35
7.4.90.0060.01617.38
7.4.80.0120.00619.39
7.4.70.0100.00717.21
7.4.60.0030.01317.38
7.4.50.0040.01117.27
7.4.40.0030.01917.32
7.4.00.0000.01315.74
7.3.330.0020.00214.19
7.3.320.0000.00614.20
7.3.310.0030.00317.27
7.3.300.0030.00317.06
7.3.290.0070.00717.25
7.3.280.0140.00617.20
7.3.260.0150.00417.27
7.3.240.0080.00917.14
7.3.230.0100.00717.19
7.3.210.0120.00617.32
7.3.200.0110.00717.29
7.3.190.0130.00317.37
7.3.180.0040.01817.18
7.3.170.0170.00017.26
7.3.160.0070.01017.39
7.3.50.0090.00615.56
7.3.40.0090.01615.27
7.3.30.0100.00515.50
7.3.20.0100.01315.30
7.3.10.0060.01115.59
7.3.00.0090.00615.58
7.2.330.0140.01117.28
7.2.320.0130.00617.53
7.2.310.0130.00317.36
7.2.300.0030.01517.29
7.2.290.0140.00317.48
7.2.180.0110.00515.55
7.2.170.0030.01315.57
7.2.160.0080.00615.74
7.2.150.0100.00715.74
7.2.140.0190.00815.68
7.2.130.0110.00415.59
7.2.120.0230.00315.70
7.2.110.0150.00015.71
7.2.100.0060.01115.83
7.2.90.0210.00715.74
7.2.80.0170.00015.52
7.2.70.0080.01215.79
7.2.60.0040.01315.91
7.2.50.0070.01015.84
7.2.40.0170.00315.66
7.2.30.0130.00715.72
7.2.20.0090.01215.92
7.2.10.0220.00315.65
7.2.00.0160.00615.88
7.1.280.0100.01014.60
7.1.270.0080.00814.15
7.1.260.0060.01214.34
7.1.250.0140.01114.62
7.1.240.0170.00314.43
7.1.230.0210.00414.57
7.1.220.0170.00614.65
7.1.210.0180.00814.51
7.1.200.0190.00014.49
7.1.190.0180.00314.40
7.1.180.0160.01014.55
7.1.170.0530.00914.62
7.1.160.0200.00314.71
7.1.150.0140.00414.64
7.1.140.0130.00714.58
7.1.130.0090.01314.55
7.1.120.0200.00614.53
7.1.110.0100.01114.67
7.1.100.0180.00914.50
7.1.90.0160.00614.56
7.1.80.0110.00614.44
7.1.70.0140.00314.73
7.1.60.0120.00614.41
7.1.50.0110.01114.67
7.1.40.0180.01414.27
7.1.30.0230.00914.58
7.1.20.0170.00414.26
7.1.10.0150.01114.40
7.1.00.0190.00614.66
7.0.330.0240.00914.00
7.0.320.0260.00614.19
7.0.310.0120.00814.28
7.0.300.0100.00714.05
7.0.290.0110.01413.96
7.0.280.0140.00714.16
7.0.270.0160.01214.25
7.0.260.0140.00713.95
7.0.250.0200.01114.01
7.0.240.0140.00714.38
7.0.230.0120.00614.00
7.0.220.0140.00514.32
7.0.210.0130.00314.32
7.0.200.0070.00714.06
7.0.190.1030.00614.13
7.0.180.0200.00014.12
7.0.170.0210.00414.00
7.0.160.0180.01114.18
7.0.150.0150.01114.00
7.0.140.0100.01314.28
7.0.130.0200.00314.22
7.0.120.0190.00914.13
7.0.110.0250.00614.13
7.0.100.0190.00814.31
7.0.90.0200.00914.32
7.0.80.1290.00915.96
7.0.70.0130.00715.90
7.0.60.0040.01115.79
7.0.50.0100.01015.80
7.0.40.0110.00415.69
7.0.30.0080.00816.08
7.0.20.0110.00715.85
7.0.10.0180.00315.89
7.0.00.0100.01015.96
5.6.400.0060.00614.81
5.6.390.0150.01614.90
5.6.380.0140.00515.13
5.6.370.0130.00314.72
5.6.360.0140.00715.01
5.6.350.0120.00814.95
5.6.340.0120.01314.85
5.6.330.0150.01414.79
5.6.320.0040.01615.03
5.6.310.0260.00415.10
5.6.300.0170.01314.88
5.6.290.0120.00515.09
5.6.280.0090.01415.11
5.6.270.0170.00814.86
5.6.260.0130.01614.63
5.6.250.0220.00414.85
5.6.240.0150.00514.77
5.6.230.0150.00514.97
5.6.220.0100.00714.98
5.6.210.0070.01314.79
5.6.200.0100.02114.61
5.6.190.0180.01314.88
5.6.180.0120.00614.97
5.6.170.0070.01114.93
5.6.160.0230.00514.81
5.6.150.0060.01514.94
5.6.140.0040.01714.98
5.6.130.0200.00014.88
5.6.120.0050.01915.02
5.6.110.0180.00914.71
5.6.100.0120.00814.89
5.6.90.0140.00515.04
5.6.80.0120.00514.89
5.6.70.0180.00714.76
5.6.60.0220.01114.76
5.6.50.0090.01815.07
5.6.40.0260.00014.84
5.6.30.0280.00514.84
5.6.20.0130.00814.85
5.6.10.0100.01014.66
5.6.00.0250.00814.74
5.5.380.0160.00813.98
5.5.370.0280.00013.94
5.5.360.0220.00013.87
5.5.350.0130.00714.28
5.5.340.0090.00913.81
5.5.330.0040.01314.17
5.5.320.0210.00013.84
5.5.310.0100.01213.96
5.5.300.0160.00414.30
5.5.290.0080.01213.73
5.5.280.0130.00713.84
5.5.270.0150.00014.01
5.5.260.0150.00714.00
5.5.250.0190.00313.76
5.5.240.0060.02113.72
5.5.230.0200.00814.16
5.5.220.0180.00413.80
5.5.210.0180.01413.69
5.5.200.0130.01313.73
5.5.190.0130.00814.02
5.5.180.0140.01413.62
5.5.170.0110.00713.83
5.5.160.0170.00713.71
5.5.150.0190.00813.58
5.5.140.0250.00513.85
5.5.130.0200.00513.60
5.5.120.0170.00813.59
5.5.110.0230.00313.98
5.5.100.0160.00613.87
5.5.90.0070.01013.77
5.5.80.0130.01013.80
5.5.70.0160.00813.59
5.5.60.0060.01214.02
5.5.50.0180.00614.00
5.5.40.0120.00614.07
5.5.30.0110.01413.76
5.5.20.0100.01014.05
5.5.10.0220.00613.90
5.5.00.0090.01514.11
5.4.450.0060.00811.26
5.4.440.0120.00811.26
5.4.430.0120.00311.26
5.4.420.0130.00011.26
5.4.410.0050.00511.26
5.4.400.0130.00011.26
5.4.390.0130.00911.26
5.4.380.0070.01411.26
5.4.370.0160.00311.26
5.4.360.0080.00611.26
5.4.350.0080.00611.26
5.4.340.0080.00511.26
5.4.330.0080.00311.26
5.4.320.0040.01211.26
5.4.310.0110.00711.26
5.4.300.0080.00811.26
5.4.290.0090.00711.26
5.4.280.0000.01211.26
5.4.270.0090.00611.26
5.4.260.0110.00911.26
5.4.250.0050.01111.26
5.4.240.0050.00911.26
5.4.230.0160.00011.26
5.4.220.0090.00311.26
5.4.210.0090.00911.26
5.4.200.0160.00311.26
5.4.190.0090.00911.26
5.4.180.0070.00711.26
5.4.170.0060.00811.26
5.4.160.0110.00811.26
5.4.150.0110.00311.26
5.4.140.0140.00711.26
5.4.130.0080.00411.26
5.4.120.0150.00311.26
5.4.110.0100.00311.26
5.4.100.0160.01011.26
5.4.90.0080.01111.26
5.4.80.0130.00011.26
5.4.70.0080.00511.26
5.4.60.0160.00611.26
5.4.50.0070.01111.26
5.4.40.0100.00311.26
5.4.30.0080.00511.26
5.4.20.0150.00511.26
5.4.10.0090.00411.26
5.4.00.0070.01311.26
5.3.290.0150.00311.26
5.3.280.0090.00411.26
5.3.270.0150.00711.26
5.3.260.0100.00711.26
5.3.250.0080.01111.26
5.3.240.0100.00311.26
5.3.230.0080.00611.26
5.3.220.0060.00611.26
5.3.210.0090.00411.26
5.3.200.0060.00911.26
5.3.190.0080.00411.26
5.3.180.0080.00811.26
5.3.170.0060.00611.26
5.3.160.0080.00411.26
5.3.150.0120.00611.26
5.3.140.0030.00911.26
5.3.130.0170.00711.26
5.3.120.0060.00611.26
5.3.110.0090.00411.26
5.3.100.0090.00311.26
5.3.90.0100.01311.26
5.3.80.0060.00611.26
5.3.70.0080.00411.26
5.3.60.0150.00211.26
5.3.50.0120.00411.26
5.3.40.0030.00911.26
5.3.30.0130.00311.26
5.3.20.0040.00711.26
5.3.10.0140.00011.26
5.3.00.0130.01011.26
5.2.170.0090.00611.26
5.2.160.0050.00711.26
5.2.150.0110.00711.26
5.2.140.0130.00411.26
5.2.130.0050.00511.26
5.2.120.0080.00311.26
5.2.110.0070.00311.26
5.2.100.0160.00311.26
5.2.90.0040.00711.26
5.2.80.0060.00611.26
5.2.70.0120.00311.26
5.2.60.0120.00311.26
5.2.50.0030.01111.26
5.2.40.0000.01311.26
5.2.30.0110.00011.26
5.2.20.0090.00611.26
5.2.10.0040.01111.26
5.2.00.0080.00311.26
5.1.60.0040.00411.26
5.1.50.0050.00511.26
5.1.40.0080.00011.26
5.1.30.0060.00311.26
5.1.20.0050.01011.26
5.1.10.0030.00711.26
5.1.00.0120.00011.26
5.0.50.0030.00511.26
5.0.40.0090.00311.26
5.0.30.0070.00311.26
5.0.20.0000.01111.26
5.0.10.0070.00011.26
5.0.00.0050.00911.26
4.4.90.0030.00311.26
4.4.80.0030.00311.26
4.4.70.0060.00011.26
4.4.60.0060.00011.26
4.4.50.0000.00611.26
4.4.40.0060.00011.26
4.4.30.0030.00311.26
4.4.20.0040.00111.26
4.4.10.0060.00011.26
4.4.00.0000.00911.26
4.3.110.0090.00211.26
4.3.100.0050.00511.26
4.3.90.0110.00011.26
4.3.80.0050.00611.26
4.3.70.0070.00011.26
4.3.60.0110.00011.26
4.3.50.0030.00511.26
4.3.40.0030.00311.26
4.3.30.0030.00211.26
4.3.20.0030.00611.26
4.3.10.0030.00711.26
4.3.00.0000.00511.26

preferences:
32.4 ms | 401 KiB | 5 Q