in reply to Re^2: Reading a VERY LARGE file with SINGLE line as content!
in thread Reading a VERY LARGE file with SINGLE line as content!
This code will run not just a "little bit" faster than a Win command line...the performance difference is HUGE, even with just 8K buffer.
That's some strange code and a big claim. I thought I test the claim and my first attempt to call bcopy copy got:
Too many arguments for main::bcopy at C:\test\junk8.pl line 34, near " +@in )"
Once I removed the useless prototype:
#! perl -sw use 5.010; use strict; sub bcopy { (my $out, my @in_list)=@_; open (OUTBIN, ">", "$out") || showfailed ("unable to open $out"); binmode(OUTBIN) || showfailed ("unable to set binmode $out"); foreach my $infile (@in_list) { open(INBIN, "<", "$infile")|| showfailed ("unable to open $infile"); binmode(INBIN) || showfailed ("unable to set binmode $infile"); while (read(INBIN, my $buff, 8 * 2**10)) { print OUTBIN $buff; } close(INBIN) || showfailed("unable to close $infile"); print "$infile appended to $out\n"; } close(OUTBIN) || showfailed("unable to close $out"); } my @in = glob shift; my $out = shift; say time; bcopy( $out, @in ); say time;
and ran it on 10x 128meg files:
[10:11:26.67} C:\test>junk8 *.jnk bigjnk.out 1247908624 bugjunk1.jnk appended to bigjnk.out bugjunk10.jnk appended to bigjnk.out bugjunk2.jnk appended to bigjnk.out bugjunk3.jnk appended to bigjnk.out bugjunk4.jnk appended to bigjnk.out bugjunk5.jnk appended to bigjnk.out bugjunk6.jnk appended to bigjnk.out bugjunk7.jnk appended to bigjnk.out bugjunk8.jnk appended to bigjnk.out bugjunk9.jnk appended to bigjnk.out 1247908656
32 seconds. Then again with xcopy:
[10:22:58.79} C:\test>xcopy /Y *.jnk bigjnk.out Does bigjnk.out specify a file name or directory name on the target (F = file, D = directory)? f C:bugjunk1.jnk C:bugjunk10.jnk C:bugjunk2.jnk C:bugjunk3.jnk C:bugjunk4.jnk C:bugjunk5.jnk C:bugjunk6.jnk C:bugjunk7.jnk C:bugjunk8.jnk C:bugjunk9.jnk 10 File(s) copied [10:23:06.51} C:\test>
Even with time it took me to respond to the dumb prompt, took just 8 seconds.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Reading a VERY LARGE file with SINGLE line as content!
by Marshall (Canon) on Jul 18, 2009 at 10:01 UTC |