Memoize one of the most under utilized modules Perl has to offer for speeding things up.
Look for comment "# Uncomment the three lines below to speed things up" to test Memoize.

#!/usr/bin/perl use strict; use warnings; use Carp qw(carp croak); use Data::Dumper; use Benchmark; my %loaded; for (qw/ Digest::MD5 /) { eval "use $_"; unless ($@) { $loaded{$_} = $_->VERSION; } } print "Benchmarking...\n"; for my $key (sort keys %loaded) { print "$key\t$loaded{$key}\n"; } my $code = <<'EOM'; [b]bold [i]italic[/i] test[/b] [code]some [perl] code[/code] [url=http://foo.example.org/]a link![/url] EOM sub Dmd5 { my $pb = Digest::MD5->new; # Uncomment the three lines below to speed things up # use Memoize; # memoize('Digest::MD5::add'); # memoize('Digest::MD5::hexdigest'); return $pb; } my ($pb); if ($loaded{'Digest::MD5'}) { $pb = Dmd5(); my $rendered1 = $pb->add($code); } timethese($ARGV[0] || -1, { $loaded{'Digest::MD5'} ? ( 'Digest::MD5::new' => \&Dmd5, 'Digest::MD5' => sub { my $out = $pb->hexdigest }, ) : (), }); #Benchmarking... #Digest::MD5 2.55 #Benchmark: running Digest::MD5, Digest::MD5::new for at least 1 CPU s +econds... #Digest::MD5: -1 wallclock secs ( 1.11 usr + 0.00 sys = 1.11 CPU) @ +138871.96/s (n=154009) #Digest::MD5::new: 1 wallclock secs ( 1.11 usr + 0.00 sys = 1.11 CP +U) @ 69872.97/s (n=77559) # #Benchmarking with Memoize... #Digest::MD5 2.55 #Benchmark: running Digest::MD5, Digest::MD5::new for at least 1 CPU s +econds... #Digest::MD5: 1 wallclock secs ( 1.12 usr + 0.00 sys = 1.12 CPU) @ +61895.11/s (n=69632) #Digest::MD5::new: 1 wallclock secs ( 1.06 usr + 0.03 sys = 1.09 CP +U) @ 5227.61/s (n=5719)

In reply to Re: Could SHA encode faster than MD5? by $h4X4_&#124;=73}{
in thread Could SHA encode faster than MD5? by bbs2web

Title:
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, details, 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, summary, 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.