3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ProceduralNumericSequenceGenerator { private $algo, $state; public function __construct($seed = NULL, $algo = "sha256") { if ($seed === NULL) { $seed = time(); } if (array_search($algo, hash_algos()) === FALSE) { throw new RuntimeException("Hashing algorithm \"$algo\" is not available."); } $this->state = $seed; $this->algo = $algo; } public function getInt() { return hexdec(substr($this->state, 0, PHP_INT_SIZE)); } public function advance() { $this->state = hash($this->algo, $this->state); } public function advanceNew() { $new = clone $this; $new->advance(); return $new; } public function advanceAndGetInt() { $this->advance(); return $this->getInt(); } public function advanceNewAndGetInt() { $new = $this->advanceNew(); return [$new->getInt(), $new]; } } $rng = new ProceduralNumericSequenceGenerator(time()); var_dump($rng->advanceAndGetInt()); $rng2 = clone $rng; var_dump($rng->advanceAndGetInt()); var_dump($rng2->advanceAndGetInt());

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)
7.4.10.0040.01414.76
7.4.00.0040.01114.63
7.3.130.0070.01414.82
7.3.120.0100.00515.10
7.3.110.0030.01014.96
7.3.100.0080.00814.79
7.3.90.0080.00414.87
7.3.80.0030.00915.14
7.3.70.0090.00615.03
7.3.60.0100.00614.88
7.3.50.0040.01115.06
7.3.40.0070.00314.93
7.3.30.0070.01014.68
7.3.20.0030.01016.80
7.3.10.0090.00316.78
7.3.00.0100.00616.73
7.2.260.0120.00615.22
7.2.250.0060.01315.02
7.2.240.0060.00815.25
7.2.230.0070.01015.07
7.2.220.0040.01115.02
7.2.210.0090.00314.82
7.2.200.0060.00915.07
7.2.190.0080.00415.14
7.2.180.0040.01114.89
7.2.170.0030.00715.07
7.2.160.0090.00315.21
7.2.150.0000.01317.00
7.2.140.0000.01116.88
7.2.130.0120.00316.94
7.2.120.0040.01116.95
7.2.110.0030.01217.10
7.2.100.0040.00816.91
7.2.90.0070.00716.65
7.2.80.0060.00916.97
7.2.70.0110.00416.88
7.2.60.0060.00416.94
7.2.50.0060.00616.82
7.2.40.0060.00317.02
7.2.30.0110.00416.96
7.2.20.0000.00916.67
7.2.10.0060.00917.12
7.2.00.0110.00318.17
7.1.330.0030.01015.79
7.1.320.0100.00315.73
7.1.310.0060.00915.66
7.1.300.0000.01415.62
7.1.290.0060.00315.78
7.1.280.0060.00615.62
7.1.270.0040.01116.04
7.1.260.0060.00615.96
7.1.250.0030.00915.91
7.1.240.0090.00015.98
7.1.230.0070.01015.86
7.1.220.0040.01115.77
7.1.210.0040.00815.98
7.1.200.0060.00715.68
7.1.190.0030.00915.71
7.1.180.0000.01515.63
7.1.170.0000.01115.87
7.1.160.0000.01515.72
7.1.150.0030.01015.79
7.1.140.0100.00715.80
7.1.130.0060.00315.97
7.1.120.0120.00315.82
7.1.110.0000.01015.89
7.1.100.0090.00716.79
7.1.90.0080.00815.61
7.1.80.0000.00816.06
7.1.70.0020.00916.38
7.1.60.0100.01017.61
7.1.50.0030.01216.29
7.1.40.0130.00315.84
7.1.30.0080.00815.61
7.1.20.0070.00415.84
7.1.10.0090.00315.75
7.1.00.0090.03919.13
7.0.330.0030.00715.23
7.0.320.0070.00715.12
7.0.310.0080.00615.47
7.0.300.0000.01415.50
7.0.290.0000.01015.55
7.0.280.0040.01115.57
7.0.270.0100.00315.27
7.0.260.0040.00915.26
7.0.250.0030.01015.44
7.0.240.0100.00315.44
7.0.230.0000.01315.41
7.0.220.0070.00715.49
7.0.210.0030.01015.34
7.0.200.0050.00816.10
7.0.190.0080.00715.28
7.0.180.0070.00715.44
7.0.170.0090.00915.30
7.0.160.0000.01315.19
7.0.150.0100.00315.41
7.0.140.0040.03918.88
7.0.130.0110.00615.52
7.0.120.0030.00615.40
7.0.110.0000.01015.46
7.0.100.0120.04617.72
7.0.90.0090.02917.70
7.0.80.0120.04117.60
7.0.70.0070.03517.68
7.0.60.0050.04017.51
7.0.50.0050.04817.81
7.0.40.0130.04116.74
7.0.30.0080.04616.86
7.0.20.0060.02816.81
7.0.10.0070.02516.73
7.0.00.0130.03916.79
5.6.400.0000.01414.54
5.6.390.0000.01514.73
5.6.380.0030.00614.72
5.6.370.0090.00014.52
5.6.360.0070.00714.75
5.6.350.0060.00614.62
5.6.340.0030.00914.18
5.6.330.0000.01714.30
5.6.320.0040.00714.61
5.6.310.0000.00914.40
5.6.300.0070.00714.37
5.6.290.0070.00714.43
5.6.280.0070.03717.64
5.6.270.0060.00314.71
5.6.260.0060.00914.43
5.6.250.0110.04017.41
5.6.240.0070.04517.38
5.6.230.0100.04317.53
5.6.220.0080.02317.57
5.6.210.0050.03017.54
5.6.200.0030.02517.75
5.6.190.0080.02817.77
5.6.180.0090.04317.67
5.6.170.0080.03517.63
5.6.160.0030.04417.71
5.6.150.0050.04817.52
5.6.140.0040.04617.81
5.6.130.0050.02917.69
5.6.120.0130.04217.88
5.6.110.0050.03017.74
5.6.100.0070.04217.80
5.6.90.0080.04317.72
5.6.80.0080.04017.39
5.6.70.0060.04317.36
5.6.60.0100.02017.31
5.6.50.0080.04217.28
5.6.40.0120.04017.31
5.6.30.0080.03817.49
5.6.20.0030.04717.38
5.6.10.0100.04217.29
5.6.00.0100.03317.35
5.5.380.0100.04217.26
5.5.370.0100.04117.49
5.5.360.0090.03817.42
5.5.350.0100.04017.36
5.5.340.0120.04317.68
5.5.330.0120.04117.73
5.5.320.0050.03517.72
5.5.310.0030.04717.48
5.5.300.0050.03417.71
5.5.290.0100.04217.72
5.5.280.0100.03717.56
5.5.270.0060.04517.41
5.5.260.0100.04217.60
5.5.250.0050.03317.19
5.5.240.0050.04217.08
5.5.230.0050.04417.23
5.5.220.0050.04617.31
5.5.210.0100.04017.10
5.5.200.0130.03517.34
5.5.190.0070.03017.16
5.5.180.0080.03817.34
5.5.170.0040.00414.25
5.5.160.0080.02717.31
5.5.150.0040.02717.34
5.5.140.0000.04317.21
5.5.130.0110.03017.32
5.5.120.0050.04617.28
5.5.110.0070.04017.27
5.5.100.0080.03217.09
5.5.90.0070.02217.22
5.5.80.0070.04717.25
5.5.70.0100.04017.14
5.5.60.0050.04217.27
5.5.50.0070.03516.98
5.5.40.0070.04317.06
5.5.30.0050.02317.23
5.5.20.0110.03717.24
5.5.10.0050.02117.32
5.5.00.0070.02216.94
5.4.450.0020.03815.38
5.4.440.0010.02815.34
5.4.430.0050.02615.22
5.4.420.0070.03215.39
5.4.410.0070.03715.30
5.4.400.0080.02815.20
5.4.390.0050.03515.21
5.4.380.0050.02715.11
5.4.370.0030.04615.18
5.4.360.0030.02715.20
5.4.350.0070.04115.18
5.4.340.0060.03815.15
5.4.330.0060.00011.27
5.4.320.0050.02315.25
5.4.310.0050.02315.07
5.4.300.0090.03815.20
5.4.290.0060.02615.13
5.4.280.0060.03915.20
5.4.270.0090.03715.09
5.4.260.0080.04015.11
5.4.250.0050.02115.15
5.4.240.0080.02115.11
5.4.230.0030.04515.19
5.4.220.0120.02315.20
5.4.210.0050.02515.08
5.4.200.0060.02515.07
5.4.190.0060.02415.15
5.4.180.0040.02715.15
5.4.170.0080.03415.11
5.4.160.0080.03815.16
5.4.150.0050.04015.21
5.4.140.0110.02913.83
5.4.130.0100.03313.82
5.4.120.0080.03813.73
5.4.110.0080.03813.82
5.4.100.0020.02313.78
5.4.90.0030.03813.82
5.4.80.0080.03013.85
5.4.70.0040.02513.85
5.4.60.0030.03913.89
5.4.50.0070.03313.87
5.4.40.0060.02113.91
5.4.30.0070.03513.86
5.4.20.0020.02713.86
5.4.10.0050.03913.87
5.4.00.0060.03413.54
5.3.290.0130.06014.70
5.3.280.0030.08314.54
5.3.270.0100.07314.54
5.3.260.0070.07714.73
5.3.250.0030.06014.61
5.3.240.0030.04014.66
5.3.230.0100.07014.54
5.3.220.0100.06014.59
5.3.210.0030.06714.60
5.3.200.0200.06014.55
5.3.190.0000.07014.56
5.3.180.0070.07714.70
5.3.170.0070.04714.64
5.3.160.0070.04014.51
5.3.150.0130.06314.50
5.3.140.0070.07714.57
5.3.130.0030.04014.70
5.3.120.0100.04714.54
5.3.110.0030.03714.59
5.3.100.0000.07713.98
5.3.90.0030.05714.04
5.3.80.0030.07014.17
5.3.70.0130.06014.05
5.3.60.0130.05314.15
5.3.50.0100.06714.02
5.3.40.0070.04314.08
5.3.30.0030.05314.03
5.3.20.0030.06713.80
5.3.10.0070.07313.80
5.3.00.0100.07013.72
5.2.170.0130.04711.29
5.2.160.0000.07011.29
5.2.150.0070.06011.29
5.2.140.0070.06711.29
5.2.130.0070.06011.29
5.2.120.0030.05711.29
5.2.110.0070.05311.29
5.2.100.0130.05311.29
5.2.90.0070.03011.29
5.2.80.0000.03311.29
5.2.70.0030.06311.29
5.2.60.0070.06311.29
5.2.50.0100.05011.29
5.2.40.0000.03311.29
5.2.30.0030.06311.29
5.2.20.0030.03311.29
5.2.10.0000.06011.29
5.2.00.0070.03011.29
5.1.60.0070.04311.29
5.1.50.0130.04711.29
5.1.40.0030.03011.29
5.1.30.0070.02711.29
5.1.20.0030.04011.29
5.1.10.0030.05311.29
5.1.00.0030.05711.29
5.0.50.0000.04311.29
5.0.40.0030.04711.29
5.0.30.0070.06011.29
5.0.20.0030.04011.29
5.0.10.0030.04311.29
5.0.00.0170.05011.29
4.4.90.0030.03311.29
4.4.80.0000.03011.29
4.4.70.0000.03311.29
4.4.60.0000.02711.29
4.4.50.0030.03311.29
4.4.40.0070.04711.29
4.4.30.0070.03011.29
4.4.20.0070.03011.29
4.4.10.0000.04011.29
4.4.00.0000.05711.29
4.3.110.0000.04011.29
4.3.100.0000.03011.29
4.3.90.0100.02711.29
4.3.80.0000.05311.29
4.3.70.0000.03311.29
4.3.60.0030.03711.29
4.3.50.0030.03311.29
4.3.40.0030.05711.29
4.3.30.0030.01711.29
4.3.20.0000.01711.29
4.3.10.0000.03711.29
4.3.00.0030.03711.29

preferences:
57.33 ms | 1816 KiB | 5 Q