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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |