3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Distribution extends SPLFixedArray { private $keyMask; public function __construct(int $digits = 1) { parent::__construct(10 ** $digits); $this->keyMask = "%0{$digits}s"; } public function current(): int { return parent::current() ?? 0; } public function key(): string { return sprintf($this->keyMask, parent::key()); } public function addValue(string $key, int $value = 1) { $this->offsetSet((int) $key, $this->offsetGet((int) $key) + $value); } } $distribution = new Distribution(4); $distribution['8'] = ($distribution['8'] ?? 0) + 1; var_dump($distribution);

Abusive script

This script was stopped while abusing our resources

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.110.0150.01517.37
8.3.100.0150.00419.30
8.3.90.0120.00026.77
8.3.80.0070.00719.36
8.3.70.0300.01017.10
8.3.60.0120.01218.31
8.3.50.0150.00524.01
8.3.40.0210.00422.53
8.3.30.0230.01719.40
8.3.20.0110.01124.18
8.3.10.0090.00924.66
8.3.00.0140.00726.16
8.2.230.0100.00320.94
8.2.220.0190.00624.06
8.2.210.0070.00726.77
8.2.200.0130.00018.88
8.2.190.0070.02017.68
8.2.180.0200.00725.92
8.2.170.0320.01619.89
8.2.160.0370.01022.96
8.2.150.0090.01225.66
8.2.140.0190.00324.66
8.2.130.0190.00426.16
8.2.120.0130.00721.05
8.2.110.0040.01219.36
8.1.290.0030.01030.84
8.1.280.0280.00925.92
8.1.270.0140.00023.99
8.1.260.0140.00026.35
8.1.250.0200.00328.09
8.1.240.0090.00619.13
7.4.120.0780.02817.62
7.4.110.0520.02717.47
7.4.100.0550.03517.68
7.4.90.0810.02317.70
7.4.80.0340.04817.48
7.4.70.0540.02917.46
7.4.60.0630.02917.48
7.4.50.0450.03117.50
7.4.40.0580.03417.50
7.4.30.1000.03017.63
7.4.20.0500.05317.78
7.4.10.0720.02417.66
7.4.00.0470.01317.81
7.3.240.0360.03217.67
7.3.230.0680.03117.41
7.3.220.0670.04517.36
7.3.210.0460.03417.66
7.3.200.0460.01917.41
7.3.190.0920.03217.65
7.3.180.0400.03017.44
7.3.170.0540.03317.40
7.3.160.0830.02517.48
7.3.150.0850.04017.52
7.3.140.0580.02617.62
7.3.130.0700.01817.39
7.3.120.0570.03517.48
7.3.110.0600.03217.49
7.3.100.0640.02517.66
7.3.90.0560.04517.55
7.3.80.0450.03617.63
7.3.70.0760.03317.46
7.3.60.0680.02717.57
7.3.50.0930.03817.52
7.3.40.0390.00317.40
7.3.30.0680.02317.49
7.3.20.0390.02817.51
7.3.10.0500.02317.54
7.3.00.0770.04117.71
7.2.340.0690.03617.58
7.2.330.0510.02917.66
7.2.320.0660.04417.48
7.2.310.0320.02917.42
7.2.300.0520.01817.66
7.2.290.0630.03517.62
7.2.280.0430.03917.67
7.2.270.0310.01917.68
7.2.260.0460.03617.70
7.2.250.0750.02417.68
7.2.240.0400.01717.78
7.2.230.0460.04017.70
7.2.220.0580.04117.64
7.2.210.0410.02817.58
7.2.200.0710.04017.57
7.2.190.0600.04617.59
7.2.180.0500.02517.69
7.2.170.0490.02617.47
7.2.160.0760.04017.63
7.2.150.0290.01317.74
7.2.140.0560.03017.86
7.2.130.0480.04117.61
7.2.120.0410.03817.86
7.2.110.0730.02717.64
7.2.100.1250.03517.57
7.2.90.0350.02617.75
7.2.80.0630.04417.55
7.2.70.0620.03117.73
7.2.60.0480.03417.85
7.2.50.0520.04217.68
7.2.40.0460.02017.65
7.2.30.0320.05717.79
7.2.20.0680.03017.69
7.2.10.0670.01517.57
7.2.00.0470.03817.60

preferences:
27.13 ms | 403 KiB | 5 Q