Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Optimizing with Caching vs. Parallelizing (MCE::Map)

by 1nickt (Abbot)
on Apr 05, 2020 at 15:17 UTC ( #11115088=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
    use strict;
    @long_seqs = sort { $b->[1] <=> $a->[1]} @long_seqs;
    say  "$_->[0]: $_->[1]" for @long_seqs[0..19];
    # say "@{$cache{$long_seqs[0][0]}}";
  2. or download this
    real    0m22.596s
    user    0m21.530s
    sys    0m1.045s
  3. or download this
    use strict; use warnings; use feature 'say';
    use Data::Dumper;
    @output = sort { $b->[1] <=> $a->[1] } @output;
    say sprintf('%s : length %s', $_->[0], $_->[1]) for @output[0..19];
  4. or download this
    real    0m4.322s
    user    0m27.992s
    sys    0m0.170s
  5. or download this
    my %cache;
    my $sets = my $gets = 0;
    sub cache_has { $gets++; exists $cache{$_[0]} }
    sub cache_set { $sets++; $cache{$_[0]} = $_[1] }
    sub cache_get { $gets++; $cache{$_[0]} }
  6. or download this
    Sets: 659,948
    Gets: 16,261,635

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://11115088]
Approved by marto
Front-paged by marto
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2020-10-20 12:18 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (210 votes). Check out past polls.