note 95958 added to class.splobjectstorage
| From: | David at OnDevice | Date: | Sun, 31 Jan 2010 15:40:38 +0000 |
| Subject: | note 95958 added to class.splobjectstorage | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-165525@lists.php.net to get a copy of this message | ||
I should have qualified with some test results- so I made some comparisons- and was shocked. But
first, the caveats- I'm not going to spam this entry with my PHP implementation, so there is a
certain amount of trust involved on your behalf that its a lean efficient implementation. Second,
that the test itself was well produced.
Taking an array of 5000 unique integers (generated before benchmark timing), I tested
SplObjectStorage and my php HashMap by iterating through the 5000 unique integers and:
i. Adding a scalar key and value to the target collection
ii. Testing for the key in the collection
iii. Getting the value for the scalar key
iv Removing the key
With error_reporting set to E_ERROR (suppressing warnings from SplObjectCollection), the results
were:
HashMap average: 0.0030831205844879 seconds
SplObjectCollection average: 6.0224056243896E-6
Thats pretty impressive on part of SplObjectCollection! The only time that my hashmap outperformed
spl was with error_reporting set to E_ALL- as would be expected because I have implemented an error
handler.
Using @ and SplObjectCollection using ArrayAccess notation does nothing to suppress the warnings
however- that is,
<?php
$spl= new SplObjectStorage;
@$spl[0]= ''; // warnings still triggered
?>
Will SplObjectCollection suppress warnings about scalar keys in the future? I hope so....
----
Server IP: 64.71.164.2
Probable Submitter: 89.101.64.145
----
Manual Page -- http://www.php.net/manual/en/class.splobjectstorage.php
Edit -- https://master.php.net/note/edit/95958
Del: integrated -- https://master.php.net/note/delete/95958/integrated
Del: useless -- https://master.php.net/note/delete/95958/useless
Del: bad code -- https://master.php.net/note/delete/95958/bad+code
Del: spam -- https://master.php.net/note/delete/95958/spam
Del: non-english -- https://master.php.net/note/delete/95958/non-english
Del: in docs -- https://master.php.net/note/delete/95958/in+docs
Del: other reasons-- https://master.php.net/note/delete/95958
Reject -- https://master.php.net/note/reject/95958
Search -- https://master.php.net/manage/user-notes.php