pfjan at yahoo.com.br
Wed Jan 28 16:41:02 UTC 2004
copying the file byte by byte incurs in a high overhead (one function
call per byte). Try using a bigger buffer. Check attached code.
ps.: i did some measuring with the code, and it still takes 1.5 the time
/bin/cp takes to copy. Anyone knows how /bin/cp does this faster ? I
would guess it somehow manages to avoid a buffer copying, maybe using
memory mapped files ...
On Wed, 2004-01-28 at 00:57, larry wrote:
> I have a problem related to the speed of copying files in C++ on
> linux. I need to automate a process to copy files from one directory
> to another for media management. Anyway, the following code is what I
> have been using and it is not nearly fast enough. The entire focus of
> this application is speed. In fact in Windows, I am getting at least 5
> times the speed from a VB app that I am using. I know I must be doing
> something wrong. I am compiling on a one processor machine and moving
> it to the test equipment which has four processors and 4 gigs or RAM.
> I wonder should I compile it there to see if it runs better or is
> there a better method for copying files from one directory to another.
> The file system is Reiserfs on a gentoo installation. The machine that
> I am compiling on is ext3 on Redhat.
> IPFile = fopen("/home/this.jpg","r");
> OPFile = fopen("/mediafiles/this.jpg","w");
> while ((c = fgetc(IPFile)) != EOF)
> fputc(c, OPFile);
> Anyway, I am at a loss. There has to be a better method than this.
> Larry Lines
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 931 bytes
Desc: not available
Url : http://lists.linux.org.au/pipermail/tuxcpprogramming/attachments/20040128/07578b0d/attachment.bin
More information about the tuxCPProgramming