File Database Access Method
-
Hi Just a question regarding the performance of CreateFile using Handler (APIs) Vs C Runtime function FILE *fp and fopen Anyone know which is faster in reading and writing text files and whether any of them has limitations or problems in usage in WinCE environment? Thank you
-
Hi Just a question regarding the performance of CreateFile using Handler (APIs) Vs C Runtime function FILE *fp and fopen Anyone know which is faster in reading and writing text files and whether any of them has limitations or problems in usage in WinCE environment? Thank you
Reading/writing text files using asynchronous handlers is complex and problematic and likely to be slower than buffered i/o. fopen() eventually uses CreateFile, etc., and now offers [nonportable] access to many of the parameters of CreateFile. My only suggestion is to wrap the FILE* in a class, or use a simple Ptr<> template. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
-
Reading/writing text files using asynchronous handlers is complex and problematic and likely to be slower than buffered i/o. fopen() eventually uses CreateFile, etc., and now offers [nonportable] access to many of the parameters of CreateFile. My only suggestion is to wrap the FILE* in a class, or use a simple Ptr<> template. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
-
A bit Deep for me.. Are you saying that fread, fwrite is asynchronous handling? or is it WriteFile, ReadFile?? Maybe you could quote an example Thanx
You stated "CreateFile using Handler" which I interpreted as meaning using asynchronous i/o since CreateFile/ReadFile/WriteFile... is used by fopen/fread/fwrite.... The latter simply buffers the i/o, which for reading and writing strings will give you better performance. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
-
You stated "CreateFile using Handler" which I interpreted as meaning using asynchronous i/o since CreateFile/ReadFile/WriteFile... is used by fopen/fread/fwrite.... The latter simply buffers the i/o, which for reading and writing strings will give you better performance. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
So u are saying using fread and fwrite is faster in performance as compared to WriteFile, ReadFile?? Sorry, i am evaluating which is better as i more used to fread and fwrite but now i exposed to another APIs WriteFile, ReadFile...The only gd thing about ReadFile is that the Handler obtained from CreateFile can be used for getting File Attributes.. Anyway, thanx for taking the time to answer my doubts
-
So u are saying using fread and fwrite is faster in performance as compared to WriteFile, ReadFile?? Sorry, i am evaluating which is better as i more used to fread and fwrite but now i exposed to another APIs WriteFile, ReadFile...The only gd thing about ReadFile is that the Handler obtained from CreateFile can be used for getting File Attributes.. Anyway, thanx for taking the time to answer my doubts
WriteFile is a low level call. It simply writes data to the disk. (The OS actually does some minor caching, but it's not significant.) fwrite() writes data to an intermediate buffer (4k by default, I believe) when the buffer fills, the buffer is written to disk using a single call to WriteFile. The same thing goes for reading data, only in reverse. So, if you are reading/writing lots of smaller strings, you will get better performance with fread/fwrite unless you implement your own caching algorithm. Note that you can get the original file handle by calling _fileno() with the proper FILE* and use that to call other functions directly (though doing any call that affects the file pointer (i.e. ReadFile, SetFilePointer, etc.) withough calling fflush first, will totally mess up the stream buffers. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke