3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[NoDiscard] function lockFile(string $path) { $handle = fopen($path, 'r+'); if (! $handle || ! flock($handle, LOCK_EX)) { throw new RuntimeException('Failed locking ' . $path); } return $handle; } // what we write function main() { lockFile($path); doSomething(); echo 'hi'; } // gets rewritten internally to something like function main() { $hidden = lockFile($path); doSomething(); echo 'hi'; unset($hidden); } // if we do assign it, we omit it all // what we write here would not get rewritten function main() { $handle = lockFile($path); doSomething(); echo 'hi'; } // if we were to ever get a "using"-like // what we write function main() { using { lockFile($path); doSomething(); } echo 'hi'; } // gets rewritten internally to something like function main() { $hidden = lockFile($path); doSomething(); unset($hidden); echo 'hi'; }

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.40.0050.00519.70
8.4.30.0240.00419.17
8.4.20.0260.00019.32
8.4.10.0170.00319.29
8.3.170.0170.00416.22
8.3.160.0180.00316.46
8.3.150.0190.00416.39
8.3.140.0180.00316.46
8.3.130.0180.00016.77
8.3.120.0190.00016.55
8.3.110.0150.00216.42
8.3.100.0050.01516.47
8.3.90.0130.00818.07
8.3.80.0180.00418.49
8.3.70.0200.00316.46
8.3.60.0180.00316.55
8.3.50.0140.00616.41
8.3.40.0150.00317.43
8.3.30.0140.00517.38
8.3.20.0140.00317.16
8.3.10.0180.00017.41
8.3.00.0180.00017.46
8.2.270.0160.00318.28
8.2.260.0110.00616.22
8.2.250.0140.00216.39
8.2.240.0120.00416.59
8.2.230.0100.00716.22
8.2.220.0200.00016.23
8.2.210.0170.00016.51
8.2.200.0140.00318.10
8.2.190.0140.00416.69
8.2.180.0170.00018.00
8.2.170.0100.01017.38
8.2.160.0190.00417.11
8.2.150.0160.00317.16
8.2.140.0170.00019.20
8.2.130.0140.00517.38
8.2.120.0170.00018.88
8.2.110.0140.00317.34
8.2.100.0160.00218.89
8.2.90.0160.00019.02
8.2.80.0150.00317.28
8.2.70.0140.00517.14
8.2.60.0160.00417.12
8.2.50.0100.01017.30
8.2.40.0170.00617.42
8.2.30.0100.01019.33
8.2.20.0190.00017.27
8.2.10.0200.00016.89
8.2.00.0150.00417.16

preferences:
134.71 ms | 1000 KiB | 7 Q