3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Rixxi\Utils; class Batch implements \ArrayAccess { /** @var int */ private $limit; /** @var int */ private $counter = 0; /** @var callable */ private $onFlush; /** @var array */ private $values = array(); /** * Callback will receive all appended values as an array. When limit is reached flush is triggered. * * @param callable * @param int */ public function __construct(callable $onFlush, $limit = 1000) { $this->onFlush = $onFlush; $this->limit = $limit; } public function __destruct() { $this->flush(); } /** * Adds value to batch. If limit is reached flush is triggered immediately. * * @param mixed */ public function append($value) { $this->values[] = $value; if (++$this->counter === $this->limit) { $this->flush(); } } /** * If at least one value was appended, calls callback and resets state. */ public function flush() { if ($this->counter !== 0) { $onFlush = $this->onFlush; // performance optimization $onFlush($this->values); $this->values = array(); $this->counter = 0; } } public function offsetExists($index) { throw new NotSupportedException('Checking existence of index is not supported use callback instead.'); } public function offsetGet($index) { throw new NotSupportedException('Retrieving values via index is not supported use callback instead.'); } public function offsetSet($index, $value) { if ($index !== NULL) { throw new InvalidArgumentException('Setting values via index is not supported use append instead.'); } $this->append($value); } public function offsetUnset($index) { throw new NotSupportedException('Batch is append only.'); } }

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.0170.00016.88
8.3.50.0130.00817.55
8.3.40.0070.01418.60
8.3.30.0040.01118.72
8.3.20.0050.00318.77
8.3.10.0080.00020.58
8.3.00.0040.00419.13
8.2.180.0070.01016.75
8.2.170.0110.00422.96
8.2.160.0070.00720.35
8.2.150.0080.00024.18
8.2.140.0090.00624.66
8.2.130.0070.00026.16
8.2.120.0110.00017.75
8.2.110.0050.00521.98
8.2.100.0070.00417.53
8.2.90.0040.00417.62
8.2.80.0060.00317.97
8.2.70.0040.00417.37
8.2.60.0000.00817.80
8.2.50.0060.00718.07
8.2.40.0030.00618.22
8.2.30.0070.00418.03
8.2.20.0000.00717.55
8.2.10.0040.00417.52
8.2.00.0050.00217.64
8.1.280.0110.00425.92
8.1.270.0070.00024.66
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0030.00723.92
8.1.230.0070.00420.95
8.1.220.0060.00317.74
8.1.210.0030.00518.98
8.1.200.0100.00017.23
8.1.190.0050.00217.39
8.1.180.0050.00318.10
8.1.170.0030.00618.89
8.1.160.0050.00218.91
8.1.150.0020.00518.59
8.1.140.0000.00817.46
8.1.130.0030.00317.85
8.1.120.0070.00017.44
8.1.110.0040.00417.43
8.1.100.0000.00717.41
8.1.90.0030.00517.42
8.1.80.0040.00417.33
8.1.70.0050.00217.40
8.1.60.0000.00917.55
8.1.50.0040.00417.35
8.1.40.0000.00817.52
8.1.30.0080.00017.66
8.1.20.0040.00417.70
8.1.10.0040.00417.41
8.1.00.0040.00417.22
8.0.300.0040.00419.90
8.0.290.0000.00716.58
8.0.280.0030.00318.29
8.0.270.0030.00317.29
8.0.260.0030.00616.79
8.0.250.0080.00016.93
8.0.240.0030.00516.96
8.0.230.0000.00716.80
8.0.220.0040.00416.75
8.0.210.0030.00316.79
8.0.200.0000.00716.89
8.0.190.0000.00816.89
8.0.180.0030.00716.84
8.0.170.0080.00016.84
8.0.160.0000.00716.88
8.0.150.0070.00316.80
8.0.140.0040.00816.69
8.0.130.0000.00513.33
8.0.120.0000.00716.76
8.0.110.0000.00716.85
8.0.100.0040.00416.74
8.0.90.0050.00216.82
8.0.80.0070.00716.89
8.0.70.0040.00416.73
8.0.60.0000.00716.90
8.0.50.0040.00416.71
8.0.30.0120.00716.82
8.0.20.0090.00916.99
8.0.10.0000.00817.07
8.0.00.0130.00816.73
7.4.330.0000.00512.95
7.4.320.0030.00316.46
7.4.300.0040.00416.61
7.4.290.0030.00316.59
7.4.280.0030.00616.44
7.4.270.0000.00716.40
7.4.260.0030.00313.21
7.4.250.0000.00816.45
7.4.240.0030.00316.48
7.4.230.0000.00716.31
7.4.220.0070.01116.36
7.4.210.0060.01016.53
7.4.200.0030.00316.45
7.4.190.0070.00016.38
7.4.160.0110.00616.58
7.4.150.0070.01016.39
7.4.140.0110.00816.43
7.4.130.0080.01116.65
7.4.120.0140.00316.46
7.4.110.0100.00716.54
7.4.100.0130.01016.46
7.4.90.0090.01216.67
7.4.80.0120.00619.39
7.4.70.0130.00316.48
7.4.60.0100.01116.29
7.4.50.0030.00516.33
7.4.40.0030.00916.41
7.4.30.0100.00616.20
7.4.00.0040.00714.45
7.3.330.0000.00613.16
7.3.320.0000.00813.06
7.3.310.0080.00016.08
7.3.300.0000.00716.06
7.3.290.0150.00616.12
7.3.280.0100.00816.18
7.3.270.0130.00716.23
7.3.260.0120.00416.50
7.3.250.0130.00616.49
7.3.240.0120.00416.32
7.3.230.0000.01616.32
7.3.210.0130.00316.25
7.3.200.0080.00916.55
7.3.190.0070.01016.30
7.3.180.0090.00916.25
7.3.170.0070.01016.16
7.3.160.0150.00416.42
7.3.120.0100.00714.93
7.3.10.0060.00916.34
7.3.00.0040.00816.72
7.2.330.0140.00716.41
7.2.320.0090.01516.29
7.2.310.0070.01516.69
7.2.300.0060.01016.45
7.2.290.0070.01316.64
7.2.130.0120.00316.83
7.2.120.0040.00816.67
7.2.110.0000.01316.50
7.2.100.0000.01416.84
7.2.90.0040.00916.80
7.2.80.0060.00916.77
7.2.70.0110.00416.98
7.2.60.0070.00416.82
7.2.50.0070.00716.84
7.2.40.0030.00716.76
7.2.30.0030.00916.88
7.2.20.0030.01016.48
7.2.10.0030.01016.86
7.2.00.0070.00918.03
7.1.250.0030.00515.70
7.1.100.0090.00318.15
7.1.70.0060.00617.00
7.1.60.0100.00719.40
7.1.50.0090.01216.90
7.1.00.0070.03022.33
7.0.200.0170.01014.34
7.0.140.0030.07722.12
7.0.120.0130.06322.19
7.0.60.0070.08319.88
7.0.50.0170.06017.89
7.0.40.0100.07317.69
7.0.30.0100.08317.69
7.0.20.0130.05017.76
7.0.10.0130.07317.70
7.0.00.0000.05017.73
5.6.280.0070.07020.87
5.6.210.0030.08320.76
5.6.200.0200.07718.19
5.6.190.0030.08718.14
5.6.180.0030.04718.16
5.6.170.0030.08018.28
5.6.160.0130.07318.29
5.6.150.0070.08018.14
5.6.140.0070.03718.21
5.6.130.0030.04018.20
5.6.120.0000.04318.23
5.6.110.0070.04718.13
5.6.100.0070.03718.16
5.6.90.0130.04018.27
5.6.80.0030.03717.55
5.6.70.0100.04017.57
5.6.60.0070.04317.66
5.6.50.0030.03717.63
5.6.40.0030.03717.63
5.6.30.0100.03017.54
5.6.20.0030.04017.57
5.6.10.0000.04017.59
5.6.00.0000.04017.57
5.5.350.0170.04720.39
5.5.340.0100.06017.96
5.5.330.0100.05318.09
5.5.320.0000.08717.94
5.5.310.0130.07318.08
5.5.300.0030.07317.96
5.5.290.0000.04317.96
5.5.280.0000.04317.98
5.5.270.0030.04017.93
5.5.260.0100.03317.92
5.5.250.0070.03317.88
5.5.240.0070.03317.40
5.5.230.0000.04017.42
5.5.220.0030.04017.36
5.5.210.0030.03717.37
5.5.200.0030.03717.34
5.5.190.0030.03717.33
5.5.180.0070.04317.31
5.5.160.0030.03717.34
5.5.150.0000.07317.30
5.5.140.0030.04017.33
5.5.130.0070.04017.31
5.5.120.0000.04317.43
5.5.110.0000.04017.43
5.5.100.0030.03717.24
5.5.90.0100.04017.20
5.5.80.0030.06317.23
5.5.70.0030.04317.20
5.5.60.0100.04317.29
5.5.50.0070.08017.22
5.5.40.0070.05017.22
5.5.30.0000.05017.17
5.5.20.0070.07717.32
5.5.10.0100.04717.22
5.5.00.0070.06017.32
5.4.450.0070.03719.46
5.4.440.0000.04019.36
5.4.430.0070.03319.35
5.4.420.0030.03719.41
5.4.410.0070.03319.23
5.4.400.0000.04019.13
5.4.390.0000.04019.13
5.4.380.0030.03719.08
5.4.370.0000.04019.27
5.4.360.0070.03719.27
5.4.350.0030.04019.10
5.4.340.0000.04018.98
5.4.320.0030.04719.04
5.4.310.0030.03719.27
5.4.300.0030.03718.98
5.4.290.0000.04019.12
5.4.280.0130.02719.14
5.4.270.0030.03719.01
5.4.260.0030.03719.13
5.4.250.0030.05319.11
5.4.240.0030.05019.04
5.4.230.0030.05718.88
5.4.220.0030.05719.26
5.4.210.0070.04318.99
5.4.200.0070.07719.05
5.4.190.0030.04319.26
5.4.180.0070.07719.08
5.4.170.0170.06319.02
5.4.160.0130.07019.02
5.4.150.0030.04719.00
5.4.140.0170.06716.40
5.4.130.0000.07016.39
5.4.120.0030.07316.46
5.4.110.0070.07016.59
5.4.100.0070.06716.38
5.4.90.0100.06716.49
5.4.80.0070.07316.23
5.4.70.0070.06016.32
5.4.60.0030.07316.33
5.4.50.0030.05316.46
5.4.40.0100.05716.45
5.4.30.0170.07016.36
5.4.20.0070.07016.29
5.4.10.0170.03716.52
5.4.00.0070.06015.75
5.3.290.0030.03714.78
5.3.280.0100.04314.66
5.3.270.0070.06714.85
5.3.260.0130.05314.66
5.3.250.0000.05314.58
5.3.240.0070.07014.66
5.3.230.0100.04714.68
5.3.220.0070.07314.57
5.3.210.0070.05314.57
5.3.200.0030.07714.55
5.3.190.0030.08314.68
5.3.180.0100.07714.65
5.3.170.0070.07714.63
5.3.160.0100.07314.62
5.3.150.0070.06714.63
5.3.140.0130.07314.60
5.3.130.0030.06014.62
5.3.120.0130.03714.61
5.3.110.0100.07014.60
5.3.100.0070.04314.05
5.3.90.0100.07314.05
5.3.80.0200.05314.07
5.3.70.0130.05314.07
5.3.60.0100.06014.11
5.3.50.0030.07314.01
5.3.40.0100.07014.02
5.3.30.0030.08013.91
5.3.20.0000.08013.71
5.3.10.0130.06313.56
5.3.00.0030.06313.70
5.2.170.0070.05010.97
5.2.160.0030.05011.11
5.2.150.0000.05011.11
5.2.140.0130.04011.09
5.2.130.0000.06011.11
5.2.120.0000.03711.10
5.2.110.0070.05711.11
5.2.100.0030.06010.88
5.2.90.0070.04711.09
5.2.80.0030.05711.08
5.2.70.0100.04311.05
5.2.60.0030.06311.19
5.2.50.0030.06711.00
5.2.40.0070.03710.99
5.2.30.0000.03310.82
5.2.20.0030.03710.86
5.2.10.0030.03310.81
5.2.00.0070.03010.61
5.1.60.0000.0279.98
5.1.50.0000.05710.14
5.1.40.0030.0509.98
5.1.30.0030.04010.27
5.1.20.0100.05010.21
5.1.10.0030.04310.00
5.1.00.0000.06010.14
5.0.50.0070.0408.57
5.0.40.0030.0438.48
5.0.30.0000.0708.19
5.0.20.0000.0478.23
5.0.10.0070.0308.24
5.0.00.0030.0478.25
4.4.90.0030.0178.13
4.4.80.0030.0178.13
4.4.70.0030.0338.13
4.4.60.0000.0278.13
4.4.50.0070.0338.13
4.4.40.0000.0238.13
4.4.30.0030.0338.13
4.4.20.0000.0178.13
4.4.10.0000.0408.13
4.4.00.0070.0538.13
4.3.110.0030.0338.13
4.3.100.0030.0308.13
4.3.90.0030.0338.13
4.3.80.0030.0238.13
4.3.70.0000.0378.13
4.3.60.0000.0408.13
4.3.50.0030.0378.13
4.3.40.0070.0438.13
4.3.30.0030.0338.13
4.3.20.0070.0308.13
4.3.10.0000.0408.13
4.3.00.0030.0338.13

preferences:
33.86 ms | 401 KiB | 5 Q