in reply to "switch$ia" but don't interpolate trailing "a"
Benchmarking interpolated strings vs. appended strings:
results in:use Benchmark; timethese( 1000000, { interp => sub {my $R = 1; my $S = "Test${R}a"}, append => sub {my $R = 1; my $S = 'Test' . $R . 'a'} });
Slightly faster to append strings together than to interpolate them, but statistically, it's a wash...Benchmark: timing 1000000 iterations of interp, manual... interp: 4 wallclock secs ( 3.68 usr + 0.05 sys = 3.73 CPU) @ 2680 +96.51/s manual: 3 wallclock secs ( 3.79 usr + -0.13 sys = 3.66 CPU) @ 2732 +24.04/s
Russ
Brainbench 'Most Valuable Professional' for Perl
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: "switch$ia" (Russ: Useless Benchmarking again)
by echo (Pilgrim) on Oct 10, 2001 at 21:19 UTC | |
by Fletch (Bishop) on Oct 10, 2001 at 21:29 UTC | |
by Russ (Deacon) on Oct 10, 2001 at 21:33 UTC |