3v4l.org

run code in 300+ PHP versions simultaneously
<?php class container { protected $storage=array(); public function add(test1 $obj) { if(!isset($this->storage[spl_object_hash($obj)])) { $this->storage[spl_object_hash($obj)]=$obj; } } } class test1 { public function __construct($s) { } } $o=new container(); $o->add(new test1("lalala")); // will be added $o->add(new test1("lololo")); // not added - NOT as expected var_dump(spl_object_hash(new test1('1')) === spl_object_hash(new test1('2')) === spl_object_hash(new test1('2')) === spl_object_hash(new test1('2'))); var_dump(spl_object_hash(new test1('2'))); $t=new test1("lalala"); $o=new container(); $o->add($t); // will be added $o->add($t); // not added - as expected var_dump($o);

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)
5.5.40.0070.05717.28
5.5.30.0030.04317.25
5.5.20.0130.06017.22
5.5.10.0070.04317.19
5.5.00.0100.07317.32
5.4.200.0030.08319.02
5.4.190.0100.07319.06
5.4.180.0100.04318.87
5.4.170.0100.07319.04
5.4.160.0230.05018.99
5.4.150.0000.05019.00
5.4.140.0130.06016.28
5.4.130.0100.07016.34
5.4.120.0000.07716.33
5.4.110.0030.07316.37
5.4.100.0070.03716.64
5.4.90.0100.06716.34
5.4.80.0000.03716.44
5.4.70.0030.04316.44
5.4.60.0070.05316.36
5.4.50.0030.07716.29
5.4.40.0170.05716.51
5.4.30.0000.07716.42
5.4.20.0130.06716.41
5.4.10.0100.07316.31
5.4.00.0030.05715.66
5.3.270.0030.04014.66
5.3.260.0030.07314.64
5.3.250.0030.05714.61
5.3.240.0100.04314.64
5.3.230.0070.07314.58
5.3.220.0030.04314.57
5.3.210.0070.06314.56
5.3.200.0100.07014.63
5.3.190.0100.07714.60
5.3.180.0070.06014.63
5.3.170.0000.04014.56
5.3.160.0070.05014.63
5.3.150.0030.05714.58
5.3.140.0070.06314.63
5.3.130.0000.08314.58
5.3.120.0100.07714.63
5.3.110.0070.05014.56
5.3.100.0100.07314.07
5.3.90.0070.08014.10
5.3.80.0100.06714.06
5.3.70.0030.05314.02
5.3.60.0130.07014.01
5.3.50.0030.07313.80
5.3.40.0030.04013.85
5.3.30.0030.03313.94
5.3.20.0070.03313.75
5.3.10.0030.04013.68
5.3.00.0030.04013.49

preferences:
138.32 ms | 1394 KiB | 7 Q