Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. File Database Access Method

File Database Access Method

Scheduled Pinned Locked Moved C / C++ / MFC
questiondatabasevisual-studioperformanceworkspace
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    IceBerG71
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • I IceBerG71

      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

      J Offline
      J Offline
      Joe Woodbury
      wrote on last edited by
      #2

      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

      I 1 Reply Last reply
      0
      • J Joe Woodbury

        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

        I Offline
        I Offline
        IceBerG71
        wrote on last edited by
        #3

        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

        J 1 Reply Last reply
        0
        • I IceBerG71

          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

          J Offline
          J Offline
          Joe Woodbury
          wrote on last edited by
          #4

          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

          I 1 Reply Last reply
          0
          • J Joe Woodbury

            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

            I Offline
            I Offline
            IceBerG71
            wrote on last edited by
            #5

            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

            J 1 Reply Last reply
            0
            • I IceBerG71

              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

              J Offline
              J Offline
              Joe Woodbury
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups