This takes less than 3 minutes each to store and then retrieve 3.2 GB of AoA to disk (1e6 arrays of ave. 100 integers):
Update: If I use -O=5.8 which translates to somewhat over 630,000 arrays of ave:100 elements, but avoids pushing my machine into swapping, the time is 10 seconds to write and 11 to read.
#! perl -sw use strict; use Data::Dump qw[ pp ]; use Time::HiRes qw[ time ]; $|++; our $O //= 3; my @AoA; $#AoA = 10 ** $O; $AoA[ $_ ] = [ 1 .. 1+rand 200 ] for 0 .. $#AoA; pp \@AoA if $O <= 2; my $start = time; open O, '>:raw', 'junk26.bin' or die $1; for ( 0 .. $#AoA ) { printf O pack 'V/A*', pack 'V*', @{ $AoA[ $_ ] }; ## switched prin +tf to print } close O; printf "Store took %.6f secs\n", time() - $start; @AoA = (); $start = time; open I, '<:raw', 'junk26.bin' or die $!; for ( 0 .. 10 ** $O ) { read( I, my $n, 4 ); read( I, my $buf, unpack 'V', $n ); $AoA[ $_ ] = [ unpack 'V*', $buf ]; } close I; printf "Retrieve took %.6f secs\n", time() - $start; pp \@AoA if $O <= 2; __END__ C:\test>junk26 -O=6 Store took 169.778000 secs Retrieve took 170.926000 secs
Resultant file is 400 MB on disk and gzips to 6 MB.
In reply to Re: Storing large data structures on disk
by BrowserUk
in thread Storing large data structures on disk
by roibrodo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |