Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: INDEX limits

by pme (Prior)
on Nov 12, 2015 at 10:20 UTC ( #1147561=note: print w/replies, xml ) Need Help??


in reply to INDEX limits

Hi clivehumby,

I think there is something wrong with the I/O here. Perl scalars can hold values up to 2^53 (see maximum value of a scalar for details). For testing purpouses I created two big files F1.DAT and F2.DAT, their size are 1GB and 2GB respectively and modified your code as follows:

use strict; use warnings; my $int2 = 2147483648; my $int4 = 2147483648 * 2; my $int8 = 2147483648 * 4; my $int16 = 2147483648 * 8; print "int2 $int2\n"; print "int4 $int4\n"; print "int8 $int8\n"; print "int16 $int16\n"; ## set up data in memory my $tm=time; my $file= $ARGV[0]; my $data; { open my $fh, '<', $file or die; local $/ = undef; $data = <$fh>; close $fh; } ## report load statistics my $str="XYZ"; my $lx=length($data); my $tmx=time-$tm; my $r=$lx/$tmx; print "File $file cached $lx bytes in $tmx seconds @ $r bs\n";
I run the script with different perl versions and the result can be found below. 5.8.9 and 5.10.1 failed but 5.20.2 worked correctly.
pme@pme-notebook: ~/Develop/workpme@pme-notebook:~/Develop/work$ perlb +rew use perl-5.8.9 A sub-shell is launched with perl-5.8.9 as the activated perl. Run 'ex +it' to finish it. pme@pme-notebook: ~/Develop/workpme@pme-notebook:~/Develop/work$ perl +pos2.pl F1.DAT int2 2147483648 int4 4294967296 int8 8589934592 int16 17179869184 File F1.DAT cached 1073741824 bytes in 9 seconds @ 119304647.111111 bs pme@pme-notebook: ~/Develop/workpme@pme-notebook:~/Develop/work$ perl +pos2.pl F1.DAT P@2 int2 2147483648 int4 4294967296 int8 8589934592 int16G17179869184 File F2.DAT cached -2147483648 bytes in 18 seconds @ -119304647.111111 + bs pme@pme-notebook: ~/Develop/workpme@pme-notebook:~/Develop/work$ exit exit pme@pme-notebook: ~/Develop/workpme@pme-notebook:~/Develop/work$ perlb +rew use perl-5.10.1 A sub-shell is launched with perl-5.10.1 as the activated perl. Run 'e +xit' to finish it. pme@pme-notebook: ~/Develop/workpme@pme-notebook:~/Develop/work$ perl +pos2.pl F2.DAT 1 int2 2147483648 int4 4294967296 int8 8589934592 int16 17179869184 File F1.DAT cached 1073741824 bytes in 8 seconds @ 134217728 bs pme@pme-notebook: ~/Develop/workpme@pme-notebook:~/Develop/work$ perl +pos2.pl F1.DAT P@2 int2 2147483648 int4 4294967296 int8 8589934592 int16 17179869184 File F2.DAT cached -2147483648 bytes in 18 seconds @ -119304647.111111 + bs pme@pme-notebook: ~/Develop/workpme@pme-notebook:~/Develop/work$ exit exit pme@pme-notebook: ~/Develop/workpme@pme-notebook:~/Develop/work$ perl +-v This is perl 5, version 20, subversion 2 (v5.20.2) built for i586-linu +x-gnu-thread-multi-64int (with 51 registered patches, see perl -V for more detail) Copyright 1987-2015, Larry Wall Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using "man perl" or "perldoc perl". If you have access to + the Internet, point your browser at http://www.perl.org/, the Perl Home Pa +ge. pme@pme-notebook: ~/Develop/workpme@pme-notebook:~/Develop/work$ perl +pos2.pl F1.DAT int2 2147483648 int4 4294967296 int8 8589934592 int16 17179869184 File F1.DAT cached 1073741824 bytes in 8 seconds @ 134217728 bs pme@pme-notebook: ~/Develop/workpme@pme-notebook:~/Develop/work$ perl +pos2.pl F1.DAT P@2 int2 2147483648 int4 4294967296 int8 8589934592 int16 17179869184 File F2.DAT cached 2147483648 bytes in 17 seconds @ 126322567.529412 b +s

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1147561]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2019-12-16 07:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?