I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
Index » Programming » C/C++ »

calculate file operation timig

sahooomprakash\′s Photo
8 Dec 06, 7:13AM
(1 reply)
calculate file operation timig
Hi, I am trying to calculate the file open time and read,write etc.. time but not able to get. my aim is.. suppose i create or open a file in window. i want to know how much time take to these opearation. i am using clock() function but its showing zero. can anybody help me... which API shall i use..

regards Om Prakasah
will\′s Photo
13 Dec 06, 7:19AM
Different computers and operating systems vary wildly in how they keep track of processor time. It's common for the internal processor clock to have a resolution somewhere between hundredths and millionths of a second.

As such its possible that the time to open a file is faster that what clock measures.

To get a better average I suggest: [list:0507a6cee9]
  • create 100 files (perhaps write a program to do this)
  • take a time measurement with clock()
  • open all 100 files (I think you can do this, so Op have a limit on the number of file handles you can have open)
  • take final time measurement.
  • calculate time and output.
[/list:u:0507a6cee9] I would then place all of the above in a larger loop and repeat 3 to 5 times to see what the influence of the system cache is. The disk cache and system cache could cause large differences in your times.

If you can't open that many files all at once, then you might like to open, then close each one - though that now will give you a time for two operations.

Anyways, thats my two pennies worth. Good luck and please post back the results.

Either way, I would expect the fopen/fclose (or whatever you're using) to be quick, since its merely checking for the existance of the file.

Currently you need to be logged in to leave a message.