I got around to incorporating your implementations into my benchmark so that I had a set of comparable figures.

For the most part there are no surprises, with your implementations coming in more or less similar to my implementations of the same algorithms. Just a few percent either way as you'd expect. There are however, two stand outs.

The first is your uuencode() version--well done for getting it to work which I never did--which proves to be some 20% faster than the next nearest pure perl solution.

The second is your C implementation of the basic mask and shift algorithm which comes out 7% to 8% faster than the other C routines. Looking at the basic mechanics I do not see any great differences that the compiler shouldn't be able to optimise away. The only difference I can see that might account for that 8% is that you aren't mortalising your return values.

I've noticed that sv_2mortal() seems more costly that you'd think it should be in the past and tried to sidestep it, but every time I have, it has led to memory leaks. When I add that to your code, the difference over the other C routines drops to 2%. Still an advantage though, so maybe your implementation is more compiler/optimiser friendly.

Many thanks for your responses, it is always instructive to see how other people code the same algorithm.

(Also, congrats that all your routines produced the same, correct output!)

Rate upuu upuu0 buk jethro salva mlut asu jmcn uu C +_.._2 Crob C_24to32 uic upuu 25622/s -- -4% -13% -48% -53% -54% -54% -56% -64% - +87% -87% -87% -88% upuu0 26597/s 4% -- -10% -46% -51% -52% -53% -54% -62% - +86% -86% -86% -87% buk 29407/s 15% 11% -- -40% -46% -47% -48% -49% -58% - +85% -85% -85% -86% jethro 49099/s 92% 85% 67% -- -10% -12% -13% -15% -30% - +74% -74% -75% -76% salva 54710/s 114% 106% 86% 11% -- -2% -3% -6% -22% - +72% -72% -72% -74% mlut 55864/s 118% 110% 90% 14% 2% -- -1% -4% -20% - +71% -71% -71% -73% asu 56264/s 120% 112% 91% 15% 3% 1% -- -3% -20% - +71% -71% -71% -73% jmcnamara 57962/s 126% 118% 97% 18% 6% 4% 3% -- -17% - +70% -70% -70% -72% uu 70207/s 174% 164% 139% 43% 28% 26% 25% 21% -- - +64% -64% -64% -66% C_24to32_2 192359/s 651% 623% 554% 292% 252% 244% 242% 232% 174% + -- -0% -1% -7% Croboticus 192543/s 651% 624% 555% 292% 252% 245% 242% 232% 174% + 0% -- -1% -7% C_24to32 194211/s 658% 630% 560% 296% 255% 248% 245% 235% 177% + 1% 1% -- -6% uic 207580/s 710% 680% 606% 323% 279% 272% 269% 258% 196% + 8% 8% 7% --

(Gah! I wish I could defeat that stupid f*** wrap algorithm!)


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^2: unpacking 6-bit values by BrowserUk
in thread unpacking 6-bit values by BrowserUk

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.