IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Array vs. Hash performance
When you push new data onto an array, Perl has to periodically grow the underlying data structure (which involves some copying). A lot of data pushed means a lot of growing/copying. With a hash, you're still growing the underlying data structure, but the impact isn't as bad, depending on the mix of keys and how they hash.

You can preallocate the array by doing something like

my @array = (undef) x 100_000;

and then assign into it by index. That'll eliminate the overhead you're seeing from push().
New Shaves a second off
Not consistently though.
Thanks.
New The fastest way to pull the file in
To get a baseline on how quickly you can get the entire file into memory, something like
\nmy $contents;\nsysopen(F, "somefile.dat");\nsysread(F, $contents, -s F);\nclose(F);\n

is about as fast as you can go in Perl. But that might not help if you need to slice the file into pieces for processing, since the pieces will need yet more memory.
     Hey Ben - Perl memory / performance research - (broomberg) - (5)
         I wouldn't expect them to allow you to save space - (jake123)
         Array vs. Hash performance - (dws) - (2)
             Shaves a second off - (broomberg) - (1)
                 The fastest way to pull the file in - (dws)
         Sorry for not responding, I've been on vacation - (ben_tilly)

There are some who call me... LRPD.
81 ms