Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^5: Shortcutting grep in boolean context

by LanX (Saint)
on Jan 03, 2017 at 23:27 UTC ( [id://1178889]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Shortcutting grep in boolean context
in thread Shortcutting grep in boolean context

Thanks, did you also test firstval() from List::MoreUtils ?

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^6: Shortcutting grep in boolean context
by perlancar (Hermit) on Jan 04, 2017 at 01:05 UTC

    I was not aware of List::MoreUtils::firstval. Okay, added it to the benchmark. It mostly has the same speed as List::Util::first, I wonder what the differences are.

    % bencher -Ilib -m PERLANCAR/grep_bool --include-participant-pattern List::
    +---------------------------+----------+-----------+-----------+------------+---------+---------+
    | participant               | dataset  | rate (/s) | time (μs) | vs_slowest |  errors | samples |
    +---------------------------+----------+-----------+-----------+------------+---------+---------+
    | List::Util::first         | notfound |      3900 |   250     |      1     | 1.8e-06 |      20 |
    | List::MoreUtils::firstval | last     |      3980 |   251     |      1.01  | 5.3e-08 |      20 |
    | List::MoreUtils::firstval | notfound |      4000 |   250     |      1     | 1.1e-06 |      20 |
    | List::Util::first         | last     |      4100 |   240     |      1     | 4.8e-07 |      20 |
    | List::Util::first         | first    |     46400 |    21.6   |     11.8   | 2.1e-08 |      31 |
    | List::MoreUtils::firstval | first    |     46406 |    21.549 |     11.788 | 1.5e-10 |      20 |
    +---------------------------+----------+-----------+-----------+------------+---------+---------+
    
      > I wonder what the differences are.

      I wouldn't be surprised if it's the same code.

      IIRC (?) were these features first introduced in List::MoreUtils and later in List::Util .

      Thanks for the benchmark, have to look closer into it.

      It's very surprising that the XS code may be so inefficient.

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1178889]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-04-19 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found