in reply to Re: RFC: List::Extract
in thread RFC: List::Extract

I like it!

I wonder, though, what the performance hit is of looping over the list twice vs. once. Without doing any benchmarking, I suspect that it depends on the size of the list and how many elements are removed/kept.

Just a thought.

Replies are listed 'Best First'.
Re^3: RFC: List::Extract
by johngg (Canon) on Nov 27, 2007 at 13:48 UTC
    I have put together a benchmark testing lodin's code and the double-grep plus merlyn's and my code against different sized arrays and sifting out differing amounts of data. I couldn't get to grips with the subroutine prototype so I took that out of merlyn's routine. Here is the code.

    Here's the results.

    It seems to show that my code has a bit of an advantage when the arrays are not too large and when less data is being sifted out. It is noticeable that merlyn's code isn't impacted the more data that is sifted whereas mine is. I guess that is because he is always building two arrays whereas my map / splice has to do more work the more data is sifted. Also note the sudden elevation of twoGreps with large arrays for the 30%, 50% and 70% sifts but not for 10% or 90%.

    I've cocked up benchmarks before, however, so take all this with a pinch of salt. I won't be surprised if somebody tells me I've done the same this time.

    I hope this is of interest.

    Cheers,

    JohnGG