Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

To get a lighter syntax you can already do something like :

my @arr_1 = map {rand 1e6} 8000; my @arr_2 = map {rand 1e6} 6000; my $cmp = { hash_values_diff => sub { my %diff3; @diff3{@arr_1} = @arr_1; delete @diff3{@arr_2}; values %diff3 ; }, using_vec => sub { my $vec = ''; vec( $vec, $_, 1 ) = 1 for @arr_2; grep !vec( $vec, $_, 1 ), @arr_1; }, hash_grep => sub { my %arr_2_hash; undef @arr_2_hash{@arr_2}; grep !exists $arr_2_hash{$_}, @arr_1; } }; cmpthese(-3, $cmp);
I do like the package approach more though, because there's no reference to a hash of refences to subs, which probably is quite unsettling for beginners. And even if they don't understand how it works, it's surely better if they at least understand the syntax to use it, instead of just copying an exemple with even weirder concepts than those they already have trouble understanding.

If you go for the package solution, you might as well have it use parent YourBenchmark, so that you can call CMP->benchmark(-5);. And you may want to add filtering of some sort, because one might want to call a function imported from another package inside of the functions that should be benchmarked. I'm sure someone could have come up with a function using something out of List::AllUtils for the exemple you gave. Edit: and you already said that with using the attributes as the tool for selecting the benchmarked subs, my bad.

In reply to Re: RFC extending to facilitate CODEHASHREF by Eily
in thread RFC extending to facilitate CODEHASHREF by LanX

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (5)
    As of 2018-04-24 02:03 GMT
    Find Nodes?
      Voting Booth?