Thread: Why is fread sometimes taking so long?

  1. #1
    Registered User
    Join Date
    Apr 2007

    Why is fread sometimes taking so long?

    Ok... I'm writting an application that loads bitmap data from a file and shows it at a specified speed... Ok, I'm having a problem with the speed of fread. At the beginning of the application, I open the file, get some info from the header and then start doing fread of each bitmap and showing it. However, these are the speeds I'm getting with each fread (in miliseconds):


    I should be getting 3~5ms of each fread, but I'm getting really slow fread lots of times... Before using fread, I was testing my application by doing a LoadBitmap and then doing a two GetDIBits to get the bmp data (exactly what my file contains now)... Doing that, I was achieving a stable 27 frames per second... As you can see, now I'm getting really poor FPSs and really unstable too... Damn, please tell me you know how to fix it...

  2. #2
    "I Win!" by U. Lose vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    1. Profiling - to be sure that the problem is fread and not some memory management that happends around
    2. Caching (read big chunks and then process them from the memory, not from disk)
    To be or not to be == true

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Portland, OR
    Sounds like some other process/program is doing a bunch of disk IO and hosing up your game.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. long int type
    By sarahr202 in forum C++ Programming
    Replies: 4
    Last Post: 05-20-2009, 12:55 PM
  2. Dev-cpp - compiler options
    By tretton in forum C Programming
    Replies: 7
    Last Post: 01-06-2006, 05:20 PM
  3. Change this program so it uses function??
    By stormfront in forum C Programming
    Replies: 8
    Last Post: 11-01-2005, 07:55 AM
  4. rehash help
    By kashifk in forum C++ Programming
    Replies: 1
    Last Post: 10-22-2003, 06:51 PM
  5. Please help me
    By teedee46 in forum C++ Programming
    Replies: 9
    Last Post: 05-06-2002, 11:28 PM
Website Security Test