bennymack has asked for the wisdom of the Perl Monks concerning the following question:
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using CORE:: with autobox
by ysth (Canon) on Feb 19, 2007 at 19:29 UTC | |
|
Re: Using CORE:: with autobox
by stvn (Monsignor) on Feb 19, 2007 at 22:53 UTC | |
by bennymack (Pilgrim) on Feb 19, 2007 at 23:43 UTC | |
by stvn (Monsignor) on Feb 20, 2007 at 02:56 UTC | |
by chocolateboy (Novice) on Mar 27, 2007 at 16:09 UTC | |
|
Re: Using CORE:: with autobox
by ferreira (Chaplain) on Feb 19, 2007 at 19:27 UTC | |
by diotalevi (Canon) on Feb 19, 2007 at 21:46 UTC |