3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface TemporaryFile { public function handle(\Closure $closure) : void; public function write(string $contents): void; public function getContents() : string; public function chmod(int $mode): void; public function getUri() : string; // aka realpath public function close() : void; } class IO { /** * @return TemporaryFile */ public static function getTemporaryFile() : TemporaryFile { return new class implements TemporaryFile { private $handle; public function __construct() { $this->handle = tmpfile(); } public function handle(\Closure $closure) : void { $closure($this->handle); } public function getContents() : string { // according to PHP docs file_get_contents has much better performance // http://php.net/manual/en/function.fread.php return file_get_contents($this->getUri()); } public function getUri() : string { return stream_get_meta_data($this->handle)['uri']; } public function close() : void { if (is_resource($this->handle)) fclose($this->handle); } public function write(string $contents): void { fwrite($this->handle, $contents); } public function chmod(int $mode): void { chmod($this->getUri(), $mode); } public function __destruct() { $this->close(); } }; } } $file = IO::getTemporaryFile(); $file->write('foo'); var_dump($file->getContents());

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.0130.00824.21
8.4.110.0090.00722.69
8.4.100.0050.00517.89
8.4.90.0130.00918.79
8.4.80.0120.00918.05
8.4.70.0150.00517.82
8.4.60.0120.00918.96
8.4.50.0120.01018.79
8.4.40.0030.00717.89
8.4.30.0140.00717.73
8.4.20.0100.01019.51
8.4.10.0060.00320.63
8.3.250.0150.00519.12
8.3.240.0140.00617.25
8.3.230.0140.00616.83
8.3.220.0030.00617.29
8.3.210.0110.00716.75
8.3.200.0040.00616.70
8.3.190.0140.00616.86
8.3.180.0110.00618.55
8.3.170.0090.00919.09
8.3.160.0070.01120.51
8.3.150.0060.01218.91
8.3.140.0060.00316.64
8.3.130.0060.00318.36
8.3.120.0100.00719.29
8.3.110.0090.00020.94
8.3.100.0060.00616.91
8.3.90.0080.00026.77
8.3.80.0060.00319.36
8.3.70.0190.00616.75
8.3.60.0120.00318.55
8.3.50.0050.00918.31
8.3.40.0090.00618.97
8.3.30.0090.00618.73
8.3.20.0040.00419.33
8.3.10.0040.00422.03
8.3.00.0040.00420.81
8.2.290.0120.00822.44
8.2.280.0070.00118.76
8.2.270.0120.00619.25
8.2.260.0070.01118.50
8.2.250.0160.00316.48
8.2.240.0040.01519.09
8.2.230.0030.00622.58
8.2.220.0050.00324.06
8.2.210.0140.00026.77
8.2.200.0030.00618.88
8.2.190.0150.00616.58
8.2.180.0140.00725.92
8.2.170.0140.00718.83
8.2.160.0110.00420.43
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0070.00020.95
8.2.110.0060.00321.06
8.2.100.0080.00417.90
8.2.90.0000.01017.91
8.2.80.0050.00317.97
8.2.70.0000.00817.93
8.2.60.0000.00817.93
8.2.50.0050.00318.22
8.2.40.0080.00020.89
8.2.30.0060.00321.30
8.2.20.0000.00718.21
8.2.10.0070.00018.02
8.2.00.0000.00719.41
8.1.330.0140.00521.91
8.1.320.0130.00816.11
8.1.310.0110.00718.26
8.1.300.0080.00820.01
8.1.290.0060.00330.84
8.1.280.0120.00625.92
8.1.270.0030.00920.68
8.1.260.0090.00626.35
8.1.250.0040.00428.09
8.1.240.0090.00023.95
8.1.230.0130.00020.91
8.1.220.0030.00517.76
8.1.210.0000.00819.02
8.1.200.0030.00717.22
8.1.190.0030.00517.35
8.1.180.0050.00318.10
8.1.170.0040.00418.57
8.1.160.0030.00618.91
8.1.150.0030.00718.84
8.1.140.0050.00217.73
8.1.130.0080.00017.44
8.1.120.0000.00717.51
8.1.110.0000.00717.45
8.1.100.0060.00317.43
8.1.90.0060.00317.50
8.1.80.0000.00717.40
8.1.70.0030.00317.54
8.1.60.0030.00617.61
8.1.50.0060.00317.54
8.1.40.0000.00817.56
8.1.30.0080.00417.67
8.1.20.0050.00217.67
8.1.10.0030.00517.51
8.1.00.0000.00817.46
8.0.300.0040.00419.68
8.0.290.0040.00416.75
8.0.280.0000.00718.54
8.0.270.0080.00016.97
8.0.260.0040.00416.91
8.0.250.0020.00517.10
8.0.240.0060.00317.11
8.0.230.0070.00016.93
8.0.220.0040.00416.93
8.0.210.0000.00716.93
8.0.200.0040.00817.02
8.0.190.0040.00416.96
8.0.180.0040.00416.96
8.0.170.0060.00316.91
8.0.160.0050.00316.89
8.0.150.0040.00416.97
8.0.140.0080.00016.90
8.0.130.0000.00613.47
8.0.120.0080.00016.96
8.0.110.0000.00717.00
8.0.100.0030.00516.88
8.0.90.0000.00816.83
8.0.80.0120.00316.96
8.0.70.0040.00417.00
8.0.60.0000.00717.02
8.0.50.0020.00516.98
8.0.30.0140.00617.10
8.0.20.0090.01017.40
8.0.10.0040.00416.93
8.0.00.0120.00716.79
7.4.330.0020.00215.55
7.4.320.0040.00416.61
7.4.300.0000.00616.64
7.4.290.0040.00416.42
7.4.280.0080.00016.51
7.4.270.0000.00716.57
7.4.260.0080.00016.59
7.4.250.0000.00816.60
7.4.240.0070.00016.53
7.4.230.0000.00716.72
7.4.220.0070.00016.42
7.4.210.0110.00916.56
7.4.200.0070.00016.43
7.4.160.0060.00916.52
7.4.140.0080.01217.86
7.4.130.0090.00916.48
7.4.120.0080.01016.58
7.4.110.0110.00616.61
7.4.100.0170.00716.67
7.4.90.0120.00616.63
7.4.80.0140.01119.39
7.4.70.0100.01016.45
7.4.60.0050.01116.48
7.4.50.0070.00716.37
7.4.40.0150.00916.62
7.4.00.0070.01114.90
7.3.330.0000.00513.29
7.3.320.0030.00313.46
7.3.310.0000.00816.45
7.3.300.0070.00016.51
7.3.290.0000.00716.29
7.3.280.0090.00616.45
7.3.260.0150.00716.50
7.3.240.0100.00816.37
7.3.230.0090.00916.64
7.3.210.0070.01016.38
7.3.200.0060.01616.62
7.3.190.0130.00316.53
7.3.180.0130.00316.39
7.3.170.0200.00716.33
7.3.160.0070.01016.44
7.3.10.0830.00814.64
7.3.00.0120.00614.77
7.2.330.0100.01316.62
7.2.320.0120.01216.79
7.2.310.0040.01816.82
7.2.300.0110.00716.72
7.2.290.0060.01316.72
7.2.130.0210.00315.00
7.2.120.0060.01314.78
7.2.110.0200.01015.02
7.2.100.0310.00615.13
7.2.90.0320.00714.90
7.2.80.0160.01015.21
7.2.70.1850.01314.90
7.2.60.0810.00616.16
7.2.50.0780.00616.12
7.2.40.1680.00716.66
7.2.30.0830.01016.51
7.2.20.1010.00716.57
7.2.10.0910.00716.62
7.2.00.0920.00716.54
7.1.250.0060.01013.95
7.1.240.1190.01314.04
7.1.230.0260.00814.03
7.1.220.0110.01413.89
7.1.210.0420.01013.99
7.1.200.0540.00714.98
7.1.190.2440.00613.88
7.1.180.1220.01713.93
7.1.170.1510.00314.05
7.1.160.1080.00915.56
7.1.150.1020.00715.59
7.1.140.1060.00715.61
7.1.130.0890.00615.62
7.1.120.1010.01315.19
7.1.110.1160.00815.33
7.1.100.0950.00715.19
7.1.90.0910.00715.33
7.1.80.0940.00615.14
7.1.70.0830.00814.73
7.1.60.1360.01823.62
7.1.50.1670.00823.50
7.1.40.0990.00723.15
7.1.30.0890.01023.33
7.1.20.1010.01323.36
7.1.10.0760.00914.27
7.1.00.0920.01014.40
7.0.330.0470.01613.71
7.0.320.0080.01913.47
7.0.310.0150.01613.57
7.0.300.1380.01013.61
7.0.290.1390.01013.59
7.0.280.1090.00713.49
7.0.270.0990.01013.57
7.0.260.1050.00313.56
7.0.250.1020.01213.62
7.0.240.1220.01313.58
7.0.230.0790.00713.42
7.0.220.0810.01113.70
7.0.210.0540.00613.54
7.0.200.2830.00713.66
7.0.190.0540.01613.39
7.0.180.0660.01113.78
7.0.170.0530.01313.75
7.0.160.0500.01013.69
7.0.150.0400.01213.54
7.0.140.0510.01413.26
7.0.130.0510.00613.57
7.0.120.0560.01713.50
7.0.110.0600.00513.38
7.0.100.0630.01113.36
7.0.90.0560.00613.72
7.0.80.2050.00313.38
7.0.70.0470.01413.77
7.0.60.0590.00713.36
7.0.50.0420.00313.44
7.0.40.0410.00713.64
7.0.30.0550.00713.91
7.0.20.0310.01413.75
7.0.10.0410.01313.52
7.0.00.0450.00013.49
5.6.380.0190.00414.12
5.6.370.0190.01114.31
5.6.360.0060.01914.19
5.6.350.0210.01414.16
5.6.340.0210.01313.88
5.6.330.0090.01513.86
5.6.320.0080.01714.01
5.6.310.0090.01413.70
5.6.300.0170.02917.37
5.6.290.0170.03217.46
5.6.280.0140.03417.49
5.6.270.0150.02917.62
5.6.260.0160.03017.56
5.6.250.0190.02817.67
5.6.240.0170.02617.42
5.6.230.0160.02917.49
5.6.220.0190.02717.38
5.6.210.0130.02917.28
5.6.200.0160.03517.38
5.6.190.0200.03017.47
5.6.180.0170.03017.26
5.6.170.0180.02617.52
5.6.160.0140.02917.41
5.6.150.0130.03217.45
5.6.140.0170.04217.39
5.6.130.0130.03417.44
5.6.120.0160.04117.45
5.6.110.0160.03317.34
5.6.100.0190.03217.53
5.6.90.0130.03817.53
5.6.80.0160.03217.04
5.6.70.0130.03517.08
5.6.60.0090.03717.07
5.6.50.0190.02916.97
5.6.40.0150.03217.05
5.6.30.0110.03017.10
5.6.20.0180.02616.89
5.6.10.0140.02817.15
5.6.00.0170.03017.06
5.5.380.0100.00610.75
5.5.370.0050.01110.88
5.5.360.0120.00910.63
5.5.350.0170.00410.98
5.5.340.0080.01110.71
5.5.330.0110.00610.86
5.5.320.0180.00710.78
5.5.310.0090.00610.85
5.5.300.0130.00711.12
5.5.290.0060.01910.82
5.5.280.0200.00310.81
5.5.270.0170.00610.66
5.5.260.0110.00410.74
5.5.250.0120.00610.99
5.5.240.0160.00510.59
5.5.230.0100.00710.82
5.5.220.0070.00410.53
5.5.210.0110.00610.65
5.5.200.0120.01210.80
5.5.190.0150.00810.80
5.5.180.0150.00410.94
5.5.170.0110.00010.84
5.5.160.0120.00810.97
5.5.150.0090.00210.70
5.5.140.0000.01310.79
5.5.130.0170.00010.72
5.5.120.0130.00010.94
5.5.110.0060.00610.73
5.5.100.0160.00310.91
5.5.90.0000.01011.00
5.5.80.0050.00810.90
5.5.70.0060.00610.44
5.5.60.0160.00010.86
5.5.50.0110.00710.58
5.5.40.0040.01110.94
5.5.30.0140.00310.91
5.5.20.0160.00510.93
5.5.10.0070.01110.97
5.5.00.0070.01110.88
5.4.450.0120.00910.93
5.4.440.0130.00610.87
5.4.430.0140.00411.00
5.4.420.0070.00810.79
5.4.410.0130.01310.92
5.4.400.0170.00610.94
5.4.390.0100.00310.87
5.4.380.0140.00910.86
5.4.370.0100.01010.87
5.4.360.0050.00510.77
5.4.350.0200.00310.95
5.4.340.0130.00510.82
5.4.330.0080.00810.88
5.4.320.0170.00811.01
5.4.310.0000.01310.62
5.4.300.0080.00410.88
5.4.290.0130.00310.43
5.4.280.0060.00610.48
5.4.270.0120.00010.95
5.4.260.0130.00410.67
5.4.250.0000.01211.03
5.4.240.0100.00210.87
5.4.230.0090.00310.93
5.4.220.0140.00010.72
5.4.210.0150.00610.87
5.4.200.0030.01010.47
5.4.190.0040.01410.70
5.4.180.0190.00010.77
5.4.170.0080.00810.79
5.4.160.0090.00910.50
5.4.150.0100.01010.48
5.4.140.0080.00410.76
5.4.130.0120.00010.74
5.4.120.0030.00911.07
5.4.110.0150.00010.87
5.4.100.0120.00610.68
5.4.90.0120.00611.02
5.4.80.0140.00210.79
5.4.70.0180.00010.81
5.4.60.0070.01110.80
5.4.50.0150.00610.89
5.4.40.0130.01010.38
5.4.30.0070.00510.77
5.4.20.0060.01310.61
5.4.10.0140.00310.74
5.4.00.0100.00510.74
5.3.290.0060.00610.32
5.3.280.0040.00910.16
5.3.270.0100.00710.33
5.3.260.0070.00710.25
5.3.250.0040.01210.25
5.3.240.0060.00610.22
5.3.230.0110.00010.21
5.3.220.0100.00310.02
5.3.210.0180.00010.26
5.3.200.0040.00710.20
5.3.190.0070.00710.33
5.3.180.0080.00610.37
5.3.170.0150.00010.25
5.3.160.0060.01210.36
5.3.150.0030.00710.29
5.3.140.0070.00310.32
5.3.130.0110.00610.38
5.3.120.0080.00510.36
5.3.110.0160.00210.38
5.3.100.0070.00710.31
5.3.90.0090.01210.19
5.3.80.0070.01110.35
5.3.70.0120.00610.29
5.3.60.0100.00510.05
5.3.50.0050.00610.25
5.3.40.0100.01010.27
5.3.30.0120.00010.13
5.3.20.0070.00710.00
5.3.10.0130.00310.06
5.3.00.0100.00810.01
5.2.170.0120.0049.34
5.2.160.0070.0079.09
5.2.150.0090.0069.38
5.2.140.0060.0039.23
5.2.130.0100.0029.27
5.2.120.0140.0009.27
5.2.110.0080.0039.00
5.2.100.0000.0109.26
5.2.90.0060.0069.06
5.2.80.0120.0009.14
5.2.70.0140.0009.20
5.2.60.0000.0099.02
5.2.50.0160.0009.26
5.2.40.0060.0129.31
5.2.30.0100.0078.99
5.2.20.0100.0068.99
5.2.10.0070.0078.99
5.2.00.0080.0088.99
5.1.60.0080.0038.99
5.1.50.0030.0038.99
5.1.40.0030.0038.99
5.1.30.0110.0008.99
5.1.20.0090.0068.99
5.1.10.0070.0078.99
5.1.00.0130.0008.99
5.0.50.0040.0118.99
5.0.40.0080.0048.99
5.0.30.0100.0008.99
5.0.20.0090.0008.99
5.0.10.0070.0078.99
5.0.00.0100.0008.99
4.4.90.0050.0008.99
4.4.80.0030.0068.99
4.4.70.0090.0038.99
4.4.60.0060.0068.99
4.4.50.0060.0068.99
4.4.40.0020.0028.99
4.4.30.0000.0058.99
4.4.20.0050.0028.99
4.4.10.0000.0108.99
4.4.00.0110.0038.99
4.3.110.0090.0008.99
4.3.100.0050.0008.99
4.3.90.0100.0008.99
4.3.80.0080.0048.99
4.3.70.0040.0088.99
4.3.60.0060.0038.99
4.3.50.0030.0038.99
4.3.40.0020.0028.99
4.3.30.0000.0088.99
4.3.20.0090.0008.99
4.3.10.0060.0028.99
4.3.00.0000.0058.99

preferences:
31.33 ms | 403 KiB | 5 Q