Copy File to USB slow??

Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Copy File to USB slow??

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Marc,

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

Antonio Linares
www.fivetechsoft.com
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Post 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
Vladimir Grigoriev
Posts: 54
Joined: Fri Oct 21, 2005 10:45 am
Location: Russia, Moscow
Contact:

Post 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
Vladimir Grigoriev
Posts: 54
Joined: Fri Oct 21, 2005 10:45 am
Location: Russia, Moscow
Contact:

Post 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?
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Post 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
Vladimir Grigoriev
Posts: 54
Joined: Fri Oct 21, 2005 10:45 am
Location: Russia, Moscow
Contact:

Post 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?
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Code: Select all

DLL32 FUNCTION COPYFILE( cExistingFileName AS LPSTR, cNewFileName AS LPSTR, lFailIfExists AS LONG ) AS BOOL;
      PASCAL FROM "CopyFileA" LIB "kernel32.dll"
EMG
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Post 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
Vladimir Grigoriev
Posts: 54
Joined: Fri Oct 21, 2005 10:45 am
Location: Russia, Moscow
Contact:

Post 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
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Post 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
Vladimir Grigoriev
Posts: 54
Joined: Fri Oct 21, 2005 10:45 am
Location: Russia, Moscow
Contact:

Post 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
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Post 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
Vladimir Grigoriev
Posts: 54
Joined: Fri Oct 21, 2005 10:45 am
Location: Russia, Moscow
Contact:

Post 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.
Post Reply