Faster file handling
Faster file handling
I re-wrote a program I had originally written in PowerBasic into PureBasic because I wanted to give it a GUI to make it easier to use. PowerBasic's DDT system is overly complex compared to PureBasic's Gadget system.
End result: The PowerBasic program finished the file in less time than it took the PureBasic program to do one percent of the file!
So I know file operations (specifically string reading and writing) can be a lot faster.
End result: The PowerBasic program finished the file in less time than it took the PureBasic program to do one percent of the file!
So I know file operations (specifically string reading and writing) can be a lot faster.
Last edited by Tipperton on Sat Aug 05, 2006 8:56 pm, edited 1 time in total.
Did you try ' FileBuffersSize(#File, size) '

Last edited by Flype on Sat Aug 05, 2006 1:03 pm, edited 2 times in total.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Code: Select all
ReadFile(0, "filein.txt")
CreateFile(1, "fileout.txt")
Repeat
sInputLine=ReadString(0)
<process record>
WriteStringN(1, sOutputLine)
Until Eof(0)
CloseFile(0)
CloseFile(1)I had ran into this before (as did other PureBasic users) and switched to PowerBasic. The problem with PowerBasic is that it assumes you know and understand Windows API programming because that's all their DDT (Dynamic Dialog Tools) system is is just built in commands that mirror the API. When I discovered that PureBasic had released version 4 I decided to try it. It's nice but it appears the file reading and writting is still as slow as it was before.
So I decided to add improved file reading and writing to the wish list/feature requests.
Tried it, increasing the buffer size from the default 4096 to 65536.Flype wrote:Is FileBuffersSize(#File, size) really hard to use ?
Considering the records average about 300 bytes each, it made little (if any) difference.
BTW: I saw references to Rings' FastFile library but it doesn't appear to be on any of the PureBasic support sites like PureProject or PureArea. Is it no longer available?
My tip is an enabled debugger as well^^
PB Is deffinitely very fast when it comes to file access, don't think VB can beat that, especially their .Net versions
PB Is deffinitely very fast when it comes to file access, don't think VB can beat that, especially their .Net versions
Visit www.sceneproject.org
Maybe this is actually the cause of the delay, rather than the disk read/write?Tipperton wrote:Code: Select all
<process record>
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Yes, the debugger is disabled.
The file is in comma separated fields and all I'm doing is combining a couple of the fields into one field, formatting a couple of others, and deleting a few others. Then writing the result to an output file.
Possibly, I've seen comments that PureBasic's string handling isn't all that fast though I'm not really doing anything all that fancy.PB wrote:Maybe this is actually the cause of the delay, rather than the disk read/write?Tipperton wrote:Code: Select all
<process record>
The file is in comma separated fields and all I'm doing is combining a couple of the fields into one field, formatting a couple of others, and deleting a few others. Then writing the result to an output file.
Continued in this thread:
http://www.purebasic.fr/english/viewtopic.php?p=155678
Because this is becomming more of a discussion rather than an enhancement request.
http://www.purebasic.fr/english/viewtopic.php?p=155678
Because this is becomming more of a discussion rather than an enhancement request.
Please stop doing such assumptions, as you seem to not be very experienced with PB (strings handling in PB is very fast). We can move a topic when it's needed, so no need to create a second one (for the next time).Tipperton wrote:Possibly, I've seen comments that PureBasic's string handling isn't all that fast though I'm not really doing anything all that fancy.
What assumptions? I've seen a number of posts that say that even in v4 that string functions aren't as fast as they could be. I'm just quoting those posts. I figure they have more PureBasic experience than I do so they must know something that I don't.Fred wrote:Please stop doing such assumptions, as you seem to not be very experienced with PB (strings handling in PB is very fast).
Noted: If this forum software is anything like what I use for the forum I run, you should be able to move this topic and merge it with the other if you wish.Fred wrote:We can move a topic when it's needed, so no need to create a second one (for the next time).
show code... please?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
The code is in this thread: http://www.purebasic.fr/english/viewtopic.php?p=155678blueznl wrote:show code... please?
The problem has been solved, it turned out to be how often I was calling a function that allowed Windows to process events in general.
Thanks anyway.



