Update:Looks like the problem was solved while I was researching it and typing up my reply. The general idea of the first paragraph still stands for any benchmarks involving a filesystem, and I'll put the rest in a readmore in case anyone's interested.

Well, for one thing, make sure you're writing the smaller file out immediately before reading it back in if you want to make sure your testing is accurate. There's a good chance your OS is buffering the write and reading the file back in from the buffer in the case of good.txt so make sure it does the same for bad.txt too.

If you still have issues with time, you may want to look at the C source for Base64.so (or whatever the shared library is called on your platform). MIME::QuotedPrint is a wrapper around MIME::Base64 and that is a wrapper for XS code.

Do you have any whitespace at the ends of lines in bad.txt (which is not the case, clearly, in good.txt)? According to RFC 2045, section 6.7, rule 3 any whitespace at the end of a line, including space and tab, must be encoded if no printable characters follow them (except that a soft line break counts as printable since it's visible in the encoded version). Those extra conversions could be exercising a hot spot in the code of Base64.so which is causing a slowdown.


In reply to Re: MIME::QuotedPrint poor performance by mr_mischief
in thread MIME::QuotedPrint poor performance by RenalPete

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.