Page 1 of 2

Copy File to USB slow??

PostPosted: Wed Apr 05, 2006 8:25 am
by Marc Vanzegbroeck
Hello,

If I copy a file of 1.6Mb using COPY FILE to a USB-stick is takes 45seconds.
The same file to the local disk take only 0.05s!!!!

Is there an other function I can use to copy the file?

Thanks,
Marc

PostPosted: Wed Apr 05, 2006 8:40 am
by Antonio Linares
Marc,

That uses to be a USB-stick hardware limitation, unless you get a faster one.

PostPosted: Wed Apr 05, 2006 9:19 am
by Marc Vanzegbroeck
Antonio,

If I copy it with explorer , it's much faster. I have also a routine that use fopen() and fwrite(), and this is also faster :roll:

Marc

PostPosted: Wed Apr 05, 2006 10:38 am
by Vladimir Grigoriev
I don't remember exactly but COPY FILE (or strictly speaking the corresponding function from EXTEND.LIB) uses a small buffer. By using fread() and fwrite() you can define a buffer as large as the maximum Clipper virtual segment size i.e. 0FFECh.
Vladimir Grigoriev

PostPosted: Wed Apr 05, 2006 10:39 am
by Enrico Maria Giordano
Try

COPYFILE( cSource, cDest )

EMG

PostPosted: Wed Apr 05, 2006 11:19 am
by Vladimir Grigoriev
Enrico, I thought that there is function __COPYFILE() in Clipper that is used in COPY FILE command.
Mentioned by you COPYFILE() function is a pure FiveWin function?

PostPosted: Wed Apr 05, 2006 11:28 am
by Marc Vanzegbroeck
Enrico,
I can't find the copyfile() function.

Vladimir, I have tried it with the fread()/fwrite() functions.
It's much faster (4.7sec) than COPY FILE (45sec), but increasing the buffer doesn't help. It even makes it slower. With a buffer of 1024bytes it takes 4.7sec, a buffer of 20000bytes result in 11.5sec

Regards,
Marc

PostPosted: Wed Apr 05, 2006 11:43 am
by Vladimir Grigoriev
It is very strange! As I know __COPYFILE() uses a buffer of size 1024 bytes also (or almost the same). The situation needs investigation. What does grab the time in this case?

PostPosted: Wed Apr 05, 2006 11:43 am
by Enrico Maria Giordano
Code: Select all  Expand view
DLL32 FUNCTION COPYFILE( cExistingFileName AS LPSTR, cNewFileName AS LPSTR, lFailIfExists AS LONG ) AS BOOL;
      PASCAL FROM "CopyFileA" LIB "kernel32.dll"


EMG

PostPosted: Wed Apr 05, 2006 12:08 pm
by Marc Vanzegbroeck
Vladimir, With a buffer of 1024 it takes 4.5sec, With a buffer of 20000 it takes 11.(sec.

Enrico, I have tried the COPYFILE() it and it's faster. :D It takes 3.7sec to copy the file..


Marc

PostPosted: Wed Apr 05, 2006 12:20 pm
by Vladimir Grigoriev
Vladimir, With a buffer of 1024 it takes 4.5sec, With a buffer of 20000 it takes 11.(sec.

I can explain this only the following way. Maybe your program uses a swap file for its virtual memory system. If you request a small block of memory then there is not any need to dwap memory on disk. If you request a large memory block a swap on disk occurs.
It is interesting do you use EMM memory? Try to use EMM memory for your Clipper program and check times anew.
As for Win API function FILECOPY() it does not use Clipper virtual memory. It allocates its own memory for copy operations. So it may be faster. On the other hand I don't know can you use ERROR object with WIN API FILECOPY() function? The Clipper function __FILECOPY() builds ERROR object inside itself.

Vladimir Grigoriev

PostPosted: Wed Apr 05, 2006 12:37 pm
by Marc Vanzegbroeck
It is interesting do you use EMM memory? Try to use EMM memory for your Clipper program and check times anew.


Where do I specify this?

Marc

PostPosted: Wed Apr 05, 2006 12:45 pm
by Vladimir Grigoriev
Open your program PROPERTIES by right mouse clicing on the shortcut. On a panel Memory (I am speaking about XP though the same should be in Win 98) there is a dropdown field Expanded (EMS) memory. Change its value from None to 8192.
Then enlarge your buffer, for example, from 1024 to 10240 and repeat testings. One for the 1024 buffer and another for the 10240 buffer.

Vladimir Grigoriev

PostPosted: Wed Apr 05, 2006 1:00 pm
by Marc Vanzegbroeck
I'm using XP-professional SP2.
If I right-click the shortcut and open the properties, I can't see the memory panel. I only can check the 'run in separate memory' checkbox.

Marc

PostPosted: Wed Apr 05, 2006 1:16 pm
by Vladimir Grigoriev
O'k Marc. I was speaking about DOS program all this time :) but FiveWin program is a Windows program so shortcuts are different for this two types of programs.
Unfortunately I don't know what Virtual Memory Manager is used in FiveWin program. This question should be addressed to Antonio Linares.
Anyway you can write a simple DOS Clipper test program and perform the same operaions for the sake of interest. In this case you will be able to set on or set off EMS memory option on the corresponding shortcut.