Dear Monks,

I'm investigating the possibility of using autobox in my day-to-day coding. The first thing I did was look into the speed penalty imposed by the use of this module.

The preliminary results seem to indicate that a lot of the additional overhead is coming from the subroutine call when using autobox vs when using the CORE:: routines directly.

#!/usr/bin/perl use strict; use warnings; use autobox; sub SCALAR::uc { CORE::uc($_[0]); } sub autobox1 { return "Hello, World\n"->uc; } no autobox; sub primitive1 { return CORE::uc "Hello, World\n"; } package main; use Benchmark; cmpthese( -1, { 'autobox1' => sub { autobox1() }, 'primitive1' => sub { primitive1() }, }); cmpthese( -1, { 'autobox2' => sub { return SCALAR::uc( "Hello, World\n" ); }, 'primitive2' => sub { return CORE::uc( "Hello, World\n" ); }, }); __END__ Rate autobox1 primitive1 autobox1 183794/s -- -78% primitive1 835106/s 354% -- Rate autobox2 primitive2 autobox2 513912/s -- -89% primitive2 4797406/s 834% --

So, I'm wondering what the feasibility of just having autobox use CORE::uc directly to do its magic rather than wrapping it in a sub and incurring the corresponding overhead.

I've tried using differnt combinations of import options as well as a sub class and hacked up version of autobox.pm thus far but to no avail.

Thanks everyone!


In reply to Using CORE:: with autobox by bennymack

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.