3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); namespace Monolog\Handler; class LogRecord implements \ArrayAccess { public function __construct( public readonly string $message, public readonly int $level, public readonly array $context, public array $extra, // only field that is modifiable in theory ) {} // ... public function offsetSet(mixed $offset, mixed $value): void { if (is_null($offset)) { throw new \LogicException('Unsupported operation'); } else { $this->{$offset} = $value; } } public function offsetExists(mixed $offset): bool { return isset($this->{$offset}); } public function offsetUnset(mixed $offset): void { throw new \LogicException('Unsupported operation'); } public function offsetGet(mixed $offset): mixed { return $this->{$offset} ?? null; } } // Record for forward-compat in V2 would be added as: // interface Record implements \ArrayAccess {} interface HandlerInterfaceV2 { public function handle(array $record): bool; } interface HandlerInterfaceV3 { public function handle(LogRecord $record): bool; } class HandlerCompatPHP81OnV2 implements HandlerInterfaceV2 { public function handle(array|LogRecord $record): bool { echo $record['message']; return false; } } class HandlerCompatPHP81OnV3 implements HandlerInterfaceV3 { public function handle(array|LogRecord $record): bool { echo $record['message']; return false; } } class HandlerCompatOnV2 implements HandlerInterfaceV2 { public function handle($record): bool { echo $record['message']; return false; } } class HandlerCompatOnV3 implements HandlerInterfaceV3 { public function handle($record): bool { echo $record['message']; return false; } } class HandlerV2Only implements HandlerInterfaceV2 { public function handle(array $record): bool { echo $record['message']; return false; } } class HandlerV3Only implements HandlerInterfaceV3 { public function handle(LogRecord $record): bool { echo $record->message; return false; } } $record = new LogRecord('foo', 100, [], []); $handler = new HandlerCompatOnV3; $handler->handle($record); $handler = new HandlerV3Only; $handler->handle($record);

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.5.70.0090.00916.75
8.5.60.0110.00816.77
8.5.50.0040.00418.60
8.5.30.0050.01220.17
8.5.20.0110.00720.14
8.5.10.0030.00520.36
8.5.00.0150.00620.14
8.4.220.0110.00719.56
8.4.210.0140.00919.59
8.4.180.0130.01019.71
8.4.170.0140.00621.82
8.4.160.0090.01221.91
8.4.150.0070.00516.88
8.4.140.0130.00817.52
8.4.130.0100.01018.78
8.4.120.0100.01119.71
8.4.110.0100.00917.95
8.4.100.0140.00617.71
8.4.90.0130.00820.44
8.4.80.0140.00719.06
8.4.70.0120.00520.57
8.4.60.0060.01020.80
8.4.50.0130.00818.79
8.4.40.0140.00719.43
8.4.30.0140.00720.69
8.4.20.0000.00917.94
8.4.10.0060.00319.57
8.3.310.0110.00518.62
8.3.300.0110.00918.54
8.3.290.0110.01120.69
8.3.280.0110.01018.22
8.3.270.0080.01116.71
8.3.260.0100.00916.38
8.3.250.0110.00818.23
8.3.240.0130.00716.55
8.3.230.0080.00216.44
8.3.220.0070.00118.86
8.3.210.0110.00916.59
8.3.200.0060.00216.63
8.3.190.0030.00519.10
8.3.180.0050.00418.91
8.3.170.0040.01117.30
8.3.160.0120.00618.53
8.3.150.0000.00816.76
8.3.140.0040.00420.90
8.3.130.0150.00318.41
8.3.120.0090.00018.38
8.3.110.0040.00418.39
8.3.50.0090.00018.36
8.2.310.0120.00718.20
8.2.300.0130.00822.16
8.2.290.0100.01016.69
8.2.280.0120.00718.70
8.2.270.0160.00316.64
8.2.260.0060.00917.03
8.2.250.0090.00618.30
8.2.240.0070.01118.05
8.2.230.0160.00318.01
8.1.340.0110.00819.71
8.1.330.0110.00715.88
8.1.320.0130.00616.18
8.1.310.0000.01418.46
8.1.300.0060.00917.90
8.1.30.0110.00717.56

preferences:
50.39 ms | 748 KiB | 5 Q