FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for CA-Clipper Copy File to USB slow??
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Copy File to USB slow??
Posted: Wed Apr 05, 2006 08:25 AM

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

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Copy File to USB slow??
Posted: Wed Apr 05, 2006 08:40 AM

Marc,

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Copy File to USB slow??
Posted: Wed Apr 05, 2006 09:19 AM

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

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 54
Joined: Fri Oct 21, 2005 10:45 AM
Copy File to USB slow??
Posted: Wed Apr 05, 2006 10:38 AM

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

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Copy File to USB slow??
Posted: Wed Apr 05, 2006 10:39 AM

Try

COPYFILE( cSource, cDest )

EMG

Posts: 54
Joined: Fri Oct 21, 2005 10:45 AM
Copy File to USB slow??
Posted: Wed Apr 05, 2006 11:19 AM

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?

Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Copy File to USB slow??
Posted: Wed Apr 05, 2006 11:28 AM

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

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 54
Joined: Fri Oct 21, 2005 10:45 AM
Copy File to USB slow??
Posted: Wed Apr 05, 2006 11:43 AM

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?

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Copy File to USB slow??
Posted: Wed Apr 05, 2006 11:43 AM
DLL32 FUNCTION COPYFILE( cExistingFileName AS LPSTR, cNewFileName AS LPSTR, lFailIfExists AS LONG ) AS BOOL;
      PASCAL FROM "CopyFileA" LIB "kernel32.dll"


EMG
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Copy File to USB slow??
Posted: Wed Apr 05, 2006 12:08 PM

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

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 54
Joined: Fri Oct 21, 2005 10:45 AM
Copy File to USB slow??
Posted: Wed Apr 05, 2006 12:20 PM
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
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Copy File to USB slow??
Posted: Wed Apr 05, 2006 12:37 PM
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
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 54
Joined: Fri Oct 21, 2005 10:45 AM
Copy File to USB slow??
Posted: Wed Apr 05, 2006 12:45 PM

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

Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Copy File to USB slow??
Posted: Wed Apr 05, 2006 01:00 PM

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

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 54
Joined: Fri Oct 21, 2005 10:45 AM
Copy File to USB slow??
Posted: Wed Apr 05, 2006 01:16 PM

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.