Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
My file to string does nor have CR characters
Message
From
23/10/2014 08:31:21
 
 
To
22/10/2014 13:53:08
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01609739
Message ID:
01609798
Views:
59
>Although it's one statement, each call to strtofile() is going to open the file (and if you're using append option) seeking to the end of the file, writing the data out, then closing the file -- in a loop that's going to kill performance (especially if there is going to be an antivirus involved). If you're calling strtofile() to append to file within a loop, you're probably better off using low-level file routines -- fopen() at the beginning (then optionally fseek() to end of the file), then within loop performing a fwrite() or fputs() (fputs appends a newline for you), then fclose() after the loop. You can optionally call fflush() after fwrite()/fputs() to make sure data is being written at that moment.

When I last tested this, here's what I found:

For writing text files, the case is murkier. For small files, StrToFile() is about a third faster than the LLFFs. However, when the string to write is more than 327,680 (which is 320 * 1024) characters, StrToFile() has a significant slowdown, and the LLFFs are faster.

There's more on the topic, including an explanation from Christof about why that is, in this paper: http://www.tomorrowssolutionsllc.com/Conference%20Sessions/We%20Used%20to%20Do%20it%20That%20Way%20But.pdf

Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform