in reply to Re^3: Best way to store/sum multiple-field records?
in thread Best way to store/sum multiple-field records?
Not only 'premature optimization is the root of all evil'; not only such a microoptimization is completely meaningless; but it's actually the other way around... declaring variables inside a loop is quite a bit faster.
Really? Go figure> (It's (much) more complicated than that!):
use strict; use warnings; use Benchmark qw( cmpthese ); my @strings = qw( USERID1|2215|Jones| USERID1|1000|Jones| USERID3|1495|Dole| USERID2|2500|Francis| USERID2|1500|Francis| ); cmpthese( -1, { outside => sub { my ( $x, $y, $z ); for (@strings) { ( $x, $y, $z ) = split /\|/; } }, outside2 => sub { my ( $x, $y, $z ); for (@strings) { ( $x, $y, $z ) = split /\|/, 3; } }, inside => sub { for (@strings) { my ( $x, $y, $z ) = split /\|/; } }, inside2 => sub { for (@strings) { my ( $x, $y, $z ) = split /\|/, 3; } }, } ); __END__ C:\test>junk Rate outside inside inside2 outside2 outside 58201/s -- -38% -71% -73% inside 93659/s 61% -- -53% -57% inside2 197610/s 240% 111% -- -10% outside2 218802/s 276% 134% 11% --
When you can explain that; then you may pontificate on the subject.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Best way to store/sum multiple-field records? (carte blanche)
by tye (Sage) on Dec 23, 2014 at 05:39 UTC | |
by Laurent_R (Canon) on Dec 23, 2014 at 19:02 UTC | |
by tye (Sage) on Dec 23, 2014 at 19:49 UTC | |
by Laurent_R (Canon) on Dec 24, 2014 at 00:22 UTC | |
by BrowserUk (Patriarch) on Dec 23, 2014 at 10:33 UTC | |
|
Re^5: Best way to store/sum multiple-field records?
by GotToBTru (Prior) on Dec 23, 2014 at 21:42 UTC | |
by BrowserUk (Patriarch) on Dec 23, 2014 at 21:49 UTC |