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

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

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

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl
    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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-28 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found