zendframework / zend-stdlib

Stdlib component from Zend Framework
BSD 3-Clause "New" or "Revised" License
384 stars 76 forks source link

Fixed FastPriorityQueue index and added the remove() function #22

Closed ezimuel closed 9 years ago

ezimuel commented 9 years ago

This PR fixes an issue with the internal index of the FastPriorityQueue and add the remove() function. This function acts like the remove method of the Zend\Stdlib\PriorityQueue but the performance are much faster (see benchmark below).

Moreover, I divided the benchmarks into separate files and I added the remove test. Here is reported a test using an Intel Core i5-2500 at 3.30GHz with 8 Gb of RAM running Ubuntu Linux 14.04 and PHP 5.5.9:

ZendBench\Stdlib\ExtractPriorityQueue
    Method Name                Iterations    Average Time      Ops/second
    ------------------------  ------------  --------------    -------------
    extractSplPriorityQueue : [5,000     ] [0.0000028611183] [349,513.68288]
    extractPriorityQueue    : [5,000     ] [0.0000032114506] [311,385.76668]
    extractFastPriorityQueue: [5,000     ] [0.0000013429165] [744,647.94234]

ZendBench\Stdlib\InsertPriorityQueue
    Method Name               Iterations    Average Time      Ops/second
    -----------------------  ------------  --------------    -------------
    insertSplPriorityQueue : [5,000     ] [0.0000019140244] [522,459.39213]
    insertPriorityQueue    : [5,000     ] [0.0000052907467] [189,009.23798]
    insertFastPriorityQueue: [5,000     ] [0.0000008188248] [1,221,262.52038]

ZendBench\Stdlib\RemovePriorityQueue
    Method Name               Iterations    Average Time      Ops/second
    -----------------------  ------------  --------------    -------------
    removePriorityQueue    : [1,000     ] [0.0008117966652] [1,231.83556]
    removeFastPriorityQueue: [1,000     ] [0.0000023496151] [425,601.62354]