3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Water { public $color = 'clear'; public $temp = 'cold'; } class Pipeline { /** * @var array The parameters to pass through */ protected $parameters = []; /** * @var \Closure[] The list of pipes that the parameters will fall through * Pipe should match function($parameter..., \Closure $next) {} */ protected $pipes = []; /** * @type \Closure The "then" closure, it will receive the parameters you pipe through */ protected $thenClosure; /** * @inheritdoc */ public function send(...$parameters) : Pipeline { $this->parameters = $parameters; return $this; } /** * @inheritdoc */ public function through($pipes) : Pipeline { $this->pipes = is_array($pipes) ? $pipes : func_get_args(); return $this; } /** * @inheritdoc */ public function then(callable $then) : Pipeline { $this->thenClosure = $then; return $this; } /** * @inheritdoc */ public function execute() { $pipes = array_reverse($this->pipes); /** @type \Closure $linked_closure */ $linked_closure = array_reduce($pipes, $this->getIterator(), $this->getInitial($this->thenClosure)); return $linked_closure(...$this->parameters); } /** * Get the iterator closure, this wraps every item in the list and injects the * @return \Closure */ protected function getIterator() : \Closure { return function ($next, $pipe) { return function (...$parameters) use ($next, $pipe) { $parameters[] = $next; return $pipe(...$parameters); }; }; } /** * The initial closure * @return \Closure */ protected function getInitial(\Closure $then) : \Closure { return function(...$parameters) use ($then) { return $then(...$parameters); }; } } // Lets make some pipes $color_water_blue_pipe = function (Water $water, callable $next_pipe) { $water->color = 'blue'; // We colored it, now we're done. Send it to the next pipe and return the result! return $next_pipe($water); }; $heat_water_pipe = function (Water $water, callable $next_pipe) { $water->temp = 'hot'; // We heated it, send it to the next pipe! return $next_pipe($water); }; // Make some water $water = new Water(); // Create our pipeline $pipeline = (new Pipeline()) ->send($water) ->through([ $color_water_blue_pipe, $heat_water_pipe ]) ->then(function($water) { return $water; }); // Run it $piped_water = $pipeline->execute(); echo "The water is {$piped_water->color} and {$piped_water->temp}!";

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.0120.00316.60
8.3.50.0110.00721.98
8.3.40.0090.00618.77
8.3.30.0110.00418.67
8.3.20.0050.00220.29
8.3.10.0090.00021.89
8.3.00.0040.00421.91
8.2.180.0120.00618.43
8.2.170.0070.00722.96
8.2.160.0090.00622.20
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0030.00620.80
8.2.120.0080.00026.35
8.2.110.0030.00719.30
8.2.100.0030.00919.57
8.2.90.0040.00417.63
8.2.80.0030.00618.77
8.2.70.0000.00817.63
8.2.60.0030.00518.05
8.2.50.0060.00318.09
8.2.40.0000.00922.32
8.2.30.0080.00019.46
8.2.20.0000.00817.91
8.2.10.0050.00218.17
8.2.00.0040.00418.19
8.1.280.0180.00025.92
8.1.270.0060.00322.05
8.1.260.0080.00028.09
8.1.250.0050.00328.09
8.1.240.0000.00923.92
8.1.230.0060.00618.95
8.1.220.0080.00017.79
8.1.210.0000.00818.77
8.1.200.0000.00817.23
8.1.190.0090.00017.23
8.1.180.0080.00018.10
8.1.170.0040.00418.51
8.1.160.0000.00720.65
8.1.150.0040.00418.95
8.1.140.0040.00419.66
8.1.130.0030.00317.73
8.1.120.0070.00317.37
8.1.110.0040.00417.52
8.1.100.0050.00317.52
8.1.90.0050.00317.49
8.1.80.0040.00417.35
8.1.70.0070.00017.47
8.1.60.0080.00017.60
8.1.50.0080.00017.45
8.1.40.0100.00017.56
8.1.30.0080.00017.69
8.1.20.0030.00617.59
8.1.10.0060.00317.48
8.1.00.0050.00217.56
8.0.300.0040.00718.77
8.0.290.0000.00716.88
8.0.280.0000.00718.41
8.0.270.0000.00717.30
8.0.260.0000.00717.33
8.0.250.0030.00517.08
8.0.240.0070.00016.96
8.0.230.0040.00416.95
8.0.220.0020.00517.04
8.0.210.0000.00716.87
8.0.200.0070.00017.10
8.0.190.0040.00417.07
8.0.180.0030.00517.04
8.0.170.0000.00817.07
8.0.160.0080.00017.00
8.0.150.0040.00416.86
8.0.140.0000.00716.86
8.0.130.0050.00013.49
8.0.120.0000.00816.87
8.0.110.0030.00516.83
8.0.100.0000.00716.79
8.0.90.0070.00016.88
8.0.80.0170.01017.03
8.0.70.0000.00817.07
8.0.60.0000.00716.86
8.0.50.0040.00416.89
8.0.30.0130.00617.30
8.0.20.0100.01017.42
8.0.10.0040.00417.00
8.0.00.0100.00816.74
7.4.330.0000.00516.83
7.4.320.0000.00716.46
7.4.300.0000.00716.61
7.4.290.0070.00016.56
7.4.280.0060.00316.56
7.4.270.0030.00316.57
7.4.260.0030.00316.54
7.4.250.0000.00716.61
7.4.240.0030.00316.62
7.4.230.0000.00716.71
7.4.220.0060.01216.64
7.4.210.0120.00316.57
7.4.200.0020.00516.71
7.4.160.0060.01116.66
7.4.150.0040.01217.40
7.4.140.0150.00717.86
7.4.130.0060.01216.45
7.4.120.0110.01116.59
7.4.110.0100.00616.40
7.4.100.0030.01416.52
7.4.90.0100.00716.69
7.4.80.0060.01819.39
7.4.70.0090.00916.47
7.4.60.0090.01216.52
7.4.50.0070.01316.42
7.4.40.0060.01016.33
7.4.30.0030.01416.60
7.4.10.0040.01414.98
7.4.00.0090.00715.08
7.3.330.0030.00613.16
7.3.320.0030.00313.34
7.3.310.0070.00016.16
7.3.300.0030.00316.22
7.3.290.0040.00416.35
7.3.280.0070.01016.30
7.3.270.0090.00917.40
7.3.260.0120.01316.47
7.3.250.0120.00716.45
7.3.240.0100.00816.32
7.3.230.0100.00716.41
7.3.210.0100.00616.42
7.3.200.0150.00919.39
7.3.190.0130.00316.59
7.3.180.0070.01116.21
7.3.170.0140.00716.41
7.3.160.0040.01316.31
7.3.130.0130.00714.88
7.3.120.0030.01314.87
7.3.110.0030.01614.62
7.3.100.0080.00714.75
7.3.90.0040.00814.75
7.3.80.0070.00714.73
7.3.70.0040.01114.99
7.3.60.0040.01114.89
7.3.50.0000.01614.94
7.3.40.0030.01014.75
7.3.30.0030.00614.93
7.3.20.0000.01116.75
7.3.10.0030.01016.64
7.3.00.0070.00716.63
7.2.330.0070.01016.52
7.2.320.0100.00716.77
7.2.310.0000.01716.74
7.2.300.0120.00616.74
7.2.290.0040.01216.84
7.2.260.0100.01014.93
7.2.250.0120.00615.11
7.2.240.0060.00915.31
7.2.230.0050.00815.32
7.2.220.0070.01015.11
7.2.210.0000.01514.99
7.2.200.0070.00715.25
7.2.190.0000.00915.25
7.2.180.0040.01115.10
7.2.170.0000.01515.31
7.2.160.0140.00015.19
7.2.150.0000.01417.02
7.2.140.0040.01116.72
7.2.130.0070.01016.90
7.2.120.0040.01217.13
7.2.110.0060.00916.77
7.2.100.0060.00916.66
7.2.90.0030.00917.21
7.2.80.0080.00317.14
7.2.70.0070.01016.68
7.2.60.0080.00616.74
7.2.50.0060.00917.04
7.2.40.0000.01417.09
7.2.30.0070.00716.95
7.2.20.0030.01416.91
7.2.10.0090.00617.01
7.2.00.0080.00518.12
7.1.330.0100.00315.96
7.1.320.0030.01415.73
7.1.310.0060.00915.77
7.1.300.0070.01015.98
7.1.290.0000.01415.71
7.1.280.0060.00615.80
7.1.270.0000.01415.80
7.1.260.0030.00615.60
7.1.250.0090.00915.54
7.1.240.0000.01015.87
7.1.230.0110.00415.79
7.1.220.0090.00315.89
7.1.210.0070.00715.98
7.1.200.0090.00315.78
7.1.190.0060.00615.79
7.1.180.0150.00315.73
7.1.170.0100.00315.99
7.1.160.0090.00615.75
7.1.150.0000.01215.96
7.1.140.0000.01315.97
7.1.130.0100.00615.53
7.1.120.0160.00015.86
7.1.110.0030.01015.95
7.1.100.0050.00516.78
7.1.90.0060.00615.75
7.1.80.0060.00315.81
7.1.70.0080.00616.44
7.1.60.0050.01417.59
7.1.50.0050.01116.38
7.1.40.0060.00815.88
7.1.30.0100.00315.85
7.1.20.0100.00715.94
7.1.10.0060.00615.95
7.1.00.0050.04219.24
7.0.330.0130.00315.39
7.0.320.0000.01715.14
7.0.310.0030.01015.41
7.0.300.0030.01415.24
7.0.290.0080.01115.39
7.0.280.0100.00515.49
7.0.270.0120.00315.64
7.0.260.0060.01415.20
7.0.250.0030.01515.54
7.0.240.0030.01015.34
7.0.230.0080.00815.44
7.0.220.0000.01515.60
7.0.210.0080.01115.36
7.0.200.0000.00815.86
7.0.190.0000.01415.51
7.0.180.0070.00315.25
7.0.170.0030.01415.52
7.0.160.0060.00315.48
7.0.150.0060.00915.48
7.0.140.0060.00615.30
7.0.130.0030.01015.56
7.0.120.0110.00315.27
7.0.110.0070.00415.50
7.0.100.0000.01415.42
7.0.90.0070.00715.62
7.0.80.0000.01115.58
7.0.70.0030.00915.46
7.0.60.0070.02418.61
7.0.50.0040.03616.75
7.0.40.0080.02216.79
7.0.30.0100.04416.89
7.0.20.0180.03816.88
7.0.10.0100.04516.85
7.0.00.0050.03616.75
5.6.400.0070.00714.18
5.6.390.0050.00514.03
5.6.380.0100.00713.80
5.6.370.0080.00614.15
5.6.360.0040.00814.31
5.6.350.0000.02014.39
5.6.340.0080.01214.28
5.6.330.0040.01414.08
5.6.320.0080.00814.31
5.6.310.0090.00614.06
5.6.300.0030.01014.36
5.6.290.0100.00014.02
5.6.280.0010.02117.69
5.6.270.0000.01114.20
5.6.260.0070.01014.06
5.6.250.0060.01314.37
5.6.240.0090.00914.13
5.6.230.0090.00314.30
5.6.220.0060.00614.10
5.6.210.0080.04017.39
5.6.200.0030.03516.02
5.6.190.0090.02617.35
5.6.180.0150.04517.43
5.6.170.0100.02517.39
5.6.160.0030.03017.35
5.6.150.0050.04516.16
5.6.140.0050.03016.13
5.6.130.0030.04816.24
5.6.120.0100.04517.54
5.6.110.0080.03017.46
5.6.100.0060.03717.52
5.6.90.0040.04917.64
5.6.80.0040.04917.15
5.6.70.0060.00314.12
5.6.60.0060.00613.98
5.6.50.0030.01014.02
5.6.40.0070.00713.89
5.6.30.0040.00413.96
5.6.20.0040.01114.23
5.6.10.0090.00613.89
5.6.00.0030.00713.85
5.5.380.0030.00614.09
5.5.370.0130.00314.10
5.5.360.0030.01013.95
5.5.350.0100.04517.20
5.5.340.0130.03315.98
5.5.330.0030.02517.01
5.5.320.0330.03517.25
5.5.310.0200.03817.13
5.5.300.0070.04316.06
5.5.290.0020.05116.05
5.5.280.0050.04217.45
5.5.270.0050.03217.31
5.5.260.0100.04017.46
5.5.250.0050.03817.25
5.5.240.0080.04717.00
5.5.230.0090.00613.71
5.5.220.0100.00713.71
5.5.210.0040.01114.05
5.5.200.0000.01513.95
5.5.190.0060.01414.02
5.5.180.0060.00913.97
5.5.170.0090.00614.01
5.5.160.0090.00614.19
5.5.150.0000.01114.18
5.5.140.0060.00813.92
5.5.130.0100.00314.18
5.5.120.0000.01414.00
5.5.110.0040.01113.93
5.5.100.0060.00613.91
5.5.90.0030.00813.88
5.5.80.0030.01014.12
5.5.70.0040.00713.74
5.5.60.0070.01013.99
5.5.50.0040.01214.05
5.5.40.0120.00313.55
5.5.30.0070.00713.91
5.5.20.0090.00613.59
5.5.10.0060.00313.79
5.5.00.0070.00313.77

preferences:
58.12 ms | 401 KiB | 5 Q