3v4l.org

run code in 300+ PHP versions simultaneously
<?php // The smallest, ugliest autowiring container. function dep_set($n, $v) { $GLOBALS['deps'][$n] = $v; } function dep_get($n) { $v = &$GLOBALS['deps'][$n]; if (!$v) $v = $n; $r = $v instanceof Closure ? new ReflectionFunction($v) : (new ReflectionClass($n))->getConstructor(); $a = []; foreach ($r->getParameters() as $i => $p) { $pc = $p->getClass(); if (!$pc) throw new Exception('Cannot magically resolve a param $' . $p->name . ' without class typehint'); $pn = $pc->name; $a[] = dep_get(isset($GLOBALS['deps'][$n . '@' . $pn]) ? $n . '@' . $pn : $pn); } $v = $v instanceof Closure ? $v(...$a) : new $v(...$a); return $v; } // Usage: class A { function __construct($a, $b) { echo $a + $b; // 3 } function b() { echo 4; } } class B { function __construct(A $a) { $a->b(); } } class C { function __construct(B $a) { } } dep_set(A::class, function () { return new A(1, 2); }); $c = dep_get(C::class); // Instantiates A, B, C and prints "34"

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.60.0060.00918.43
8.3.50.0100.00718.03
8.3.40.0110.00418.81
8.3.30.0080.00818.75
8.3.20.0080.00020.30
8.3.10.0000.00820.90
8.3.00.0030.00520.95
8.2.180.0100.01017.00
8.2.170.0090.00622.96
8.2.160.0120.00319.52
8.2.150.0000.00825.66
8.2.140.0040.00424.66
8.2.130.0030.00626.16
8.2.120.0070.00021.02
8.2.110.0030.00621.18
8.2.100.0130.00317.99
8.2.90.0040.00417.88
8.2.80.0030.00618.91
8.2.70.0040.00417.75
8.2.60.0050.00318.22
8.2.50.0040.00418.10
8.2.40.0040.00422.11
8.2.30.0080.00019.32
8.2.20.0040.00418.20
8.2.10.0070.00018.25
8.2.00.0070.00018.18
8.1.280.0090.00625.92
8.1.270.0000.00822.14
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00420.96
8.1.230.0070.00420.90
8.1.220.0030.00517.79
8.1.210.0050.00518.77
8.1.200.0040.00417.38
8.1.190.0040.00417.48
8.1.180.0050.00318.10
8.1.170.0040.00418.64
8.1.160.0000.00719.02
8.1.150.0040.00418.82
8.1.140.0070.00019.47
8.1.130.0060.00318.91
8.1.120.0000.00717.47
8.1.110.0040.00417.43
8.1.100.0030.00417.42
8.1.90.0040.00417.43
8.1.80.0040.00417.54
8.1.70.0050.00217.36
8.1.60.0030.00617.53
8.1.50.0040.00417.55
8.1.40.0000.00817.46
8.1.30.0080.00017.67
8.1.20.0090.00017.63
8.1.10.0000.00817.59
8.1.00.0000.00717.50
8.0.300.0040.00418.77
8.0.290.0040.00416.88
8.0.280.0030.00318.51
8.0.270.0030.00316.81
8.0.260.0000.00718.89
8.0.250.0040.00417.04
8.0.240.0000.00717.03
8.0.230.0000.00717.00
8.0.220.0030.00316.86
8.0.210.0060.00316.87
8.0.200.0040.00417.04
8.0.190.0030.00517.07
8.0.180.0050.00317.01
8.0.170.0000.00816.95
8.0.160.0040.00416.93
8.0.150.0040.00416.82
8.0.140.0000.00716.96
8.0.130.0000.00513.36
8.0.120.0040.00416.82
8.0.110.0030.00316.95
8.0.100.0080.00016.86
8.0.90.0040.00416.97
8.0.80.0190.00316.95
8.0.70.0040.00416.96
8.0.60.0050.00316.86
8.0.50.0040.00416.84
8.0.30.0110.00717.12
8.0.20.0100.01117.41
8.0.10.0040.00416.89
8.0.00.0030.01416.61
7.4.330.0000.00515.55
7.4.320.0040.00416.63
7.4.300.0030.00316.62
7.4.290.0070.00016.59
7.4.280.0000.00716.59
7.4.270.0030.00316.54
7.4.260.0090.00016.60
7.4.250.0030.00316.47
7.4.240.0040.00416.48
7.4.230.0000.00716.64
7.4.220.0130.00316.62
7.4.210.0030.01216.54
7.4.200.0040.00416.61
7.4.160.0120.01016.51
7.4.150.0080.01217.40
7.4.140.0130.00517.86
7.4.130.0190.00516.53
7.4.120.0100.00816.64
7.4.110.0110.01116.54
7.4.100.0000.02116.59
7.4.90.0060.01316.47
7.4.80.0090.00919.39
7.4.70.0000.01616.48
7.4.60.0080.00816.38
7.4.50.0130.00316.62
7.4.40.0120.00316.57
7.4.30.0060.01116.45
7.4.00.0100.00715.05
7.3.330.0050.00013.41
7.3.320.0030.00313.37
7.3.310.0070.00016.28
7.3.300.0050.00216.25
7.3.290.0080.00816.38
7.3.280.0060.01016.36
7.3.270.0060.01817.40
7.3.260.0110.00716.39
7.3.250.0120.00516.52
7.3.240.0100.00816.40
7.3.230.0130.00416.65
7.3.210.0160.00016.43
7.3.200.0100.00716.43
7.3.190.0050.01116.55
7.3.180.0110.00816.41
7.3.170.0120.01216.58
7.3.160.0060.00916.53
7.3.10.0030.01016.47
7.3.00.0110.00316.80
7.2.330.0120.00616.69
7.2.320.0130.00316.58
7.2.310.0130.00316.84
7.2.300.0030.01316.81
7.2.290.0100.00716.60
7.2.130.0080.00417.15
7.2.120.0060.00917.02
7.2.110.0030.01416.80
7.2.100.0040.00816.93
7.2.90.0040.01117.07
7.2.80.0090.00616.67
7.2.70.0150.00016.79
7.2.60.0020.01016.91
7.2.50.0000.01416.39
7.2.40.0000.01316.40
7.2.30.0030.01116.92
7.2.20.0040.00416.95
7.2.10.0040.00716.91
7.2.00.0060.00616.97
7.1.250.0040.00715.70
7.1.200.0080.00315.73
7.1.70.0060.01117.34
7.1.60.0140.01735.20
7.1.50.0250.01134.79
7.1.40.0240.01134.50
7.1.30.0240.01034.32
7.1.20.0190.01934.75
7.1.10.0090.00616.47
7.1.00.0030.01316.43
7.0.200.0090.00716.97
7.0.190.0040.01316.64
7.0.180.0060.01216.17
7.0.170.0030.01216.45
7.0.160.0030.01316.41
7.0.150.0110.00816.29
7.0.140.0080.00616.35
7.0.130.0070.01516.45
7.0.120.0000.01416.48
7.0.110.0070.00716.29
7.0.100.0080.00816.25
7.0.90.0040.01216.29
7.0.80.0030.01216.28
7.0.70.0090.00616.34
7.0.60.0080.00516.21
7.0.50.0090.00616.34
7.0.40.0100.00316.39
7.0.30.0040.01016.43
7.0.20.0120.00616.35
7.0.10.0090.00916.54
7.0.00.0000.01416.45

preferences:
63.04 ms | 400 KiB | 5 Q