Jump to content
  • Advertisement
Sign in to follow this  
Tuesdays Gone

Calculating File Access Time

This topic is 4412 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to write a program that calculates the access time for a file. Files will be kept in a directory of thousands of other files and i need to figure out what impact increasing the number of files in the given directory has on access. so my first test would be access text file blah.txt in a directory of 4000 text files then do the same but with say 2000 text files and so on then compare the results. now my method for doing the actual calculations would be this... 1.start profile timer 2.open the file (fopen) 3.close the file(fclose) 4.end profile timer now i was pondering wether or not i need to read (fread) between steps 2 & 3. but i cant see how that affects the access time( which is all im interested in) but it would be nice to hear your opinions on the matter. so does this seem like a reasonable method for calculating the access time for a file my googling only turned up a dissertation on calculating the access time for floppy disks but it wasnt helpfull so id like to hear your thoughts on the matter if theres a standard way of doing this or if my method is missing something (or completly wrong) id greatly appreciate your input. thanks!

Share this post


Link to post
Share on other sites
Advertisement
One problem I see is that many I/O-operations are performed asynchronously. Operating systems enqueue the operations you request and may delay until a more convenient time.
So, I don't think there is a guarantee (correct me if I'm wrong) that after fopen and fclose, the access of your file has actually happened. Consequently, I don't think this method would guarantee that what you measure is actually the file access time.
To get more accurate results, I think you may need to tinker with some device drivers (be careful, you can break things!).

Your goal, you say, is determining the impact of increasing the number of files in a directory. Problem here is that access time is dependant on a lot of things: physical location of the file on disk, the current location of the disk's read head, the OS' scheduling algorithm, other processes performing I/O, etc.
Why would you determine this impact?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!