in reply to Re6: Idiomatic optimizations
in thread Idiomatic optimizations

HOWEVER, scrutinizing the Benchmark code reveals that *it* in fact string evals.

I don't see how it can possibly get something useful out of a sub reference's stringification, but I'm too lazy to look at Benchmark's source. Let's try something different:

#!/usr/bin/perl -w use Benchmark qw(cmpthese); sub single { $foo = 'foo' } sub double { $foo = "foo" } cmpthese (10000000, { single => sub { single() }, double => sub { double() } });
What does that show on your system?

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.

Replies are listed 'Best First'.
Re2: Re6: Idiomatic optimizations
by belg4mit (Prior) on May 01, 2002 at 21:13 UTC
    It yields a negligible difference 1-3% which I would attribute to system noise. Interestingly(?) it takes much no longer to run, or at least reports more wallclock seconds (15-19 vs 2 or 3 of the other (although it was obviously longer than that)).

    --
    perl -pew "s/\b;([mnst])/'$1/g"